1

Having WSO2 5.0.0 trying to implement the store and forward pattern with a JDBC message store.

Sending a message to the target endpoint throws an exception:

TID: [-1234] [] [2016-12-05 23:25:24,874] ERROR {org.apache.synapse.message.processor.impl.sampler.SamplingService} -  Error occurred while executing the message {org.apache.synapse.message.processor.impl.sampler.SamplingService}
org.apache.synapse.SynapseException: Unexpected error during sending message out
    at org.apache.synapse.core.axis2.Axis2Sender.handleException(Axis2Sender.java:257)
    at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:84)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:548)
    at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:382)
    at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:65)
    at org.apache.synapse.endpoints.IndirectEndpoint.send(IndirectEndpoint.java:55)
    at org.apache.synapse.mediators.builtin.CallMediator.handleNonBlockingCall(CallMediator.java:221)
    at org.apache.synapse.mediators.builtin.CallMediator.mediate(CallMediator.java:99)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
    at org.apache.synapse.message.processor.impl.sampler.SamplingService$1.run(SamplingService.java:211)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:538)
    at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:78)
    ... 15 more

I believe I am missing an important transport, Axis2 or Synapse property, but I am unable to find which one.

Sequences to store and forward are here.

I was trying to find out in the source codes what could be causing the NullPointerException, but for me it makes no sense as the httpMethod and messageType is defined.

Thank you all for any hint

Edit: based on a comment, the Synapse source in use is here.

Community
  • 1
  • 1
gusto2
  • 11,210
  • 2
  • 17
  • 36
  • The NPE is get thrown from the https://github.com/wso2/wso2-synapse/blob/release-2.1.7-wso2v6/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java#L538 – Thusitha Thilina Dayaratne Dec 06 '16 at 09:05
  • Oh, thanks for the update. What would be best way to resolve this issue? it looks like the originalInMsgCtx or getOperationContext() could be null :( – gusto2 Dec 06 '16 at 09:07
  • hmm. I guess most probably originalInMsgCtx.getOperationContext() is null. if originalInMsgCtx is null u should have get NPE before come to that line – Thusitha Thilina Dayaratne Dec 06 '16 at 09:16
  • 1
    I think you can get rid of this issue by injecting the message into a proxy service from the scheduled task rather than injecting to the sequence. Inside the proxy service, Your sequence can be called. Can you try that way? – Thusitha Thilina Dayaratne Dec 06 '16 at 09:30
  • Good idea, I will try it out. – gusto2 Dec 06 '16 at 09:31

1 Answers1

0

Where is your Message Processor here? Ideally your Message Processor should call the backend service using the call mediator. Can you please try out the steps as below.

  1. Create a proxy service to accept messages and store them in your JDBC store using the store mediator inside that.
  2. Then create a Scheduled Message Forwarding Processor which listens to the above JDBC store and forwards messages to the endpoint. If you need you can specify any reply sequence. Otherwise make sure you set following property inside your proxy service above. <property name="OUT_ONLY" value="true" />
  3. If you still can not figure out the error get the wire logs by enabling the log4j.logger.httpclient.wire.header=DEBUG log4j.logger.httpclient.wire.content=DEBUG in log4j.properties file and post it here so that I can analyze and help you out.
  4. If you need guaranteed delivery, you have to use the Message Forwarding processor. Sampling processor is used to implement throttling related usecases which may lead to message loss.
  5. For more information please refer the article [1]. Don't use the same synapse configuration since it is bit obsoleted, instead create artifacts using ESB web interface or developer studio. Otherwise you may run into different errors due to missing configurations.

[1] http://wso2.com/library/articles/2014/01/guaranteed-delivery-with-Message-Store-Message-Processor%20/

Ravindra Ranwala
  • 20,744
  • 6
  • 45
  • 63
  • Thank you all, indeed using the forwarding processor with a local proxy (to do some job before calling an external services) does the job. I'm still little bit fighting with a JDBC store backed by PostgreSQL (I will open another thread when I find no solution in reasonable time). – gusto2 Dec 06 '16 at 10:39