Before reading or sending messages to a queue it is necessary to get an instance of the public web service interface.
SoapToJmsClient wsClient = new SoapToJmsClient("http://server.location/contextPath");
To configure more parameters the constructor with Soap2JmsConfiguration can be used.
String queueName = "...";
S2JMessage[] messages = ...;
ResponseStatus result = wsClient.sendMessages(queueName, messages);
A simple text message can be created as follow:
S2JMessage message = new S2JTextMessage(null, "test content");
Properties that can not be set sending a message:
ResponseStatus result = null;
try {
...
result = wsClient.sendMessages(queueName, messages);
} catch (Exception e) {
// if exception is threw means that there is a protocol or configuration error.
// none of the messages has been delivered
}
if (result.getErrorCount() == 0) {
//everything all right, all messages were delivered.
}
Message delivery status can be one of:
See MessageDeliveryStatus for more information. Messages with status IN_DOUBT should be retransmitted. In case the consumer (server side) it is not idempotent, users can specify a parameter clientId when creating the message. It can be any sort of message identifier (for instance a primary key on the database).
String clientId = ..; //some client generated identifier
S2JMessage message = new S2JTextMessage(clientId, "test content");
Messages with status ERROR can be retransmitted. If it is the case it is important to implement a retransmission counter to prevent a message to be retransmitted forever.