Issue while dispatching message

Posted by chetanparekh on 25-Jan-2011 04:54

I have created FTP Custom Service which is copying content from FTP file and sending that content in xqmessage.

But I am facing problem with this custom Service.

When only this FTP custom service is present in process I am getting message at the exit point of process.

BUt when I add any other service after this Custom FTP service then I am not getting message at exit point of process,

I tried to track down message flow in whichI am getting message till the entry of message into Custom Service not regrading exit of message

I am adding part of custom Service code here

public

..

..

void service(XQServiceContext ctx) throws XQServiceException {

dispatchMessage(MessageContent, ctx);

}

Below is dispatch method

public

void dispatchMessage(String content, XQServiceContext svcContext)

throws XQException {

XQEnvelope envelope =

null;

XQEnvelopeFactory envFactory = svcContext.getEnvelopeFactory();

XQMessageFactory messageFactory = svcContext.getMessageFactory();

envelope = envFactory.createDefaultEnvelope();

XQMessage message = messageFactory.createMessage();

XQPart part = message.createPart();

part.setContent(content, XQConstants.

CONTENT_TYPE_XML);

message.addPart(part);

// Set message properties.

// Set the message in the dispatch envelope

envelope.setMessage(message);

// Dispatch the message.

XQDispatch dispatcher = svcContext.getDispatcher();

dispatcher.dispatch(envelope);

}

What could be the reason of this problem?

All Replies

Posted by sk185050 on 25-Jan-2011 05:01

can try after comment this line

XQDispatch dispatcher = svcContext.getDispatcher(); dispatcher.dispatch(envelope);

Posted by chetanparekh on 25-Jan-2011 05:14

Still I am getting same issue after commneting

XQDispatch dispatcher = svcContext.getDispatcher(); dispatcher.dispatch(envelope);

Posted by sk185050 on 25-Jan-2011 05:31

Can you try

xqEnvelope.setMessage(incomingMessage);

// Dispatching message

xqServiceContext.addOutgoing(xqEnvelope);

After you did your custom code in service.

Posted by tsteinbo on 25-Jan-2011 08:13

When you want something available at the next step/exit of your step you should not use the dispatcher. Rather, use the service context's addOutgoing() method inside your service() method.

The dispatcher is designed for asynchrnous cases, e.g. because you either not running in the context of a process or you are indeed doing some async processing.

Thomas

Posted by chetanparekh on 25-Jan-2011 08:22

Hi Thomos,

When I tried to use dispatcher it didnt work but when I choose addOutgoing() ,it worked properly

What could be reson for my issue when I am using dispatcher.dispatch method?

Yashwant

Posted by mnair on 25-Jan-2011 09:38

Hi,

As Thomas explained, you are seeing this behavior because the dispatch API is not intended for continuing the ESB process but for sending (dispatching) a message to an ESB address.

For the message to arrive at the next step in the process the service has to address the message to its outbox (using the addOutgoing API as suggested by others on this thread).

Thanks

-Mahesh

This thread is closed