The following code and pseudocode outline example implementations for senders.
This section contains an outline of a sender handler implementation. You should add protocol-specific code.
public class CustomJMSSender implements SenderInterface { SenderResult result = new SenderResult(); Config deliveryConfig; public CustomJMSSender() { ... } public void init(Context context, Config deliveryConfig) throws BCGSenderException { // initialization code // deliveryConfig gives the gateway configuration this.deiveryConfig = deliveryConfig; // initialize sender using gateway configuration. ... } public SenderResult send(BusinessDocumentInterface document) { try { // Obtain configuration information from gateway configuration. // from the configuration and document, determine destination details // for sending like queue names, JMS connection details, retries, // business protocol specific transport headers and so forth. ... // get the document to send File documentFile = document.getDocument(); // read the file contents. // establish transport connection. construct transport message. // send the transport message. perform retries if error. ... // check if response is desired String syncResp = document.getAttribute( BCGDocumentConstants.BCG_GET_SYNC_RESPONSE); if (syncResp.compareToIgnoreCase("true")){ // read the response from the response queue ... // create response file File responseFile = document.createFile(); // store the response on to file system ... // set the response in the result result.setResponse(responseFile); } // close transport connection ... // set the send status result.setSendStatus(BCGDocumentConstants.BCG_SENT_STATUS_SUCCESS); } catch(Exception ex) { //create an event and add to the sender result String[] params = new String[1]; params[0] = "CustomJMSSender.send failure: " + ex.getMessage(); EventInfo eventInfo = EventInfo("BCG250008", document, params); result.addEvent(eventInfo); result.setSendStatus(BCGDocumentConstants.BCG_SENT_STATUS_FAILED); } return result; } public SenderResult cancel(){ // if currently sending a document, cancel the sending. // update the send status appropriately. ... return result; } }