Skip to content

Commit

Permalink
Merge pull request #13 from OSGP/feature/FDP-1868-async-requests
Browse files Browse the repository at this point in the history
FDP-1868: Make soap client calls async
  • Loading branch information
jasperkamerling authored Dec 20, 2023
2 parents 9bc7174 + 2400c90 commit 3eed09a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ public void handleIncomingRequest(final ProxyServerRequestMessage proxyServerReq
final String commonName = proxyServerRequestMessage.getCommonName();
final String soapPayload = proxyServerRequestMessage.getSoapPayload();

final boolean result = soapClient.sendRequest(connectionId, context, commonName, soapPayload);
if (!result) {
LOGGER.error("Unsuccessful at sending request to platform.");
} else {
LOGGER.debug("Successfully sent response message to queue");
}
soapClient.sendRequest(connectionId, context, commonName, soapPayload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.gxf.soapbridge.valueobjects.ProxyServerResponseMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/** This {@link @Component} class can send SOAP messages to the Platform. */
Expand Down Expand Up @@ -54,10 +55,9 @@ public SoapClient(
* @param context The part of the URL indicating the SOAP web-service.
* @param commonName The common name (organisation identification).
* @param soapPayload The SOAP message to send to the platform.
* @return True if the request has been sent and the response has been received and written to a
* queue, false otherwise.
*/
public boolean sendRequest(
@Async
public void sendRequest(
final String connectionId,
final String context,
final String commonName,
Expand All @@ -70,7 +70,7 @@ public boolean sendRequest(
connection = createConnection(context, soapPayload, commonName);
if (connection == null) {
LOGGER.warn("Could not create connection for sending SOAP request.");
return false;
return;
}

// Send the SOAP payload to the server.
Expand All @@ -89,13 +89,11 @@ public boolean sendRequest(
// Send queue message.
proxyReponseSender.send(responseMessage);

return true;
} catch (final Exception e) {
if (connection != null) {
connection.disconnect();
}
LOGGER.error("Unexpected exception while sending SOAP request", e);
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ package org.gxf.soapbridge
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.boot.runApplication
import org.springframework.scheduling.annotation.EnableAsync
import org.springframework.web.servlet.config.annotation.EnableWebMvc

@SpringBootApplication
@EnableWebMvc
@EnableAsync
@ConfigurationPropertiesScan
class SoapBridgeApplication

Expand Down

0 comments on commit 3eed09a

Please sign in to comment.