Hi, Is there are any way to initialize the endpoint? I used the same code as the [1] and [2]. I modified the inbound endpoint section in the carbon-mediation.
[1] https://github.com/wso2-dev/carbon-mediation/blob/master/components/inbound-endpoints/org.wso2.carbon.inbound.endpoint/src/main/java/org/wso2/carbon/inbound/endpoint/protocol/file/FileInjectHandler.java [2] https://github.com/wso2-dev/carbon-mediation/blob/master/components/inbound-endpoints/org.wso2.carbon.inbound.endpoint/src/main/java/org/wso2/carbon/inbound/endpoint/protocol/jms/JMSInjectHandler.java My implementation for the invoke method as follows, I think problem with that public boolean invoke(MqttMessage mqttMessage) { > > try { > > org.apache.synapse.MessageContext msgCtx = >> createMessageContext(); > > String contentType = null; > > if (log.isDebugEnabled()) { > > log.debug("Processed MQTT Message of Content-type : " + >> contentType); > > } > > MessageContext axis2MsgCtx = >> ((org.apache.synapse.core.axis2.Axis2MessageContext) msgCtx) > > .getAxis2MessageContext(); > > // Determine the message builder to use > > Builder builder; > > if (contentType == null) { > > log.debug("No content type specified. Using SOAP >> builder."); > > builder = new SOAPBuilder(); > > } else { > > int index = contentType.indexOf(';'); > > String type = index > 0 ? contentType.substring(0, index) >> : contentType; > > builder = BuilderUtil.getBuilderFromSelector(type, >> axis2MsgCtx); > > if (builder == null) { > > if (log.isDebugEnabled()) { > > log.debug("No message builder found for type '" + >> type > > + "'. Falling back to SOAP."); > > } > > builder = new SOAPBuilder(); > > } > > } > > OMElement documentElement = null; > > > > String message = mqttMessage.toString(); > > InputStream in = new AutoCloseInputStream(new >> ByteArrayInputStream( > > message.getBytes())); > > documentElement = builder.processDocument(in, contentType, >> axis2MsgCtx); > > >> // Inject the message to the sequence. > > >> msgCtx.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement)); > > if (injectingSeq == null || injectingSeq.equals("")) { > > log.error("Sequence name not specified. Sequence : " + >> injectingSeq); > > return false; > > } > > SequenceMediator seq = (SequenceMediator) >> synapseEnvironment.getSynapseConfiguration() > > .getSequence(injectingSeq); > > seq.setErrorHandler(onErrorSeq); > > if (seq != null) { > > if (log.isDebugEnabled()) { > > log.debug("injecting message to sequence : " + >> injectingSeq); > > } > > if(!synapseEnvironment.injectInbound(msgCtx, seq, >> sequential)){ > > return false; > > } > > } else { > > log.error("Sequence: " + injectingSeq + " not found"); > > } > > > > } catch (Exception e) { > > log.error("Error while processing the MQTT Message"); > > } > > return true; > > } > > On Mon, Jan 12, 2015 at 12:15 PM, Chanaka Cooray <[email protected]> wrote: > Hi, > I will check that. > Thanks and regards > > On Mon, Jan 12, 2015 at 12:04 PM, Awanthika Senarath <[email protected]> > wrote: > >> Hi Chanaka, >> >> You have not copied the dev list :) >> >> AFAIK for the send mediator you should have the endpoint you have given >> being active (initialized), since you are trying to send the messages to >> that endpoint, which i believe is an address endpoint in this case >> according to your error log, >> >> In case you already have the endpoint URL you have given to the send >> mediator initialized, >> I came across a jira [1] which might be related to your issue. >> >> [1] https://wso2.org/jira/browse/ESBJAVA-2846 >> >> thanks and regards >> Awanthika >> >> On Mon, Jan 12, 2015 at 11:47 AM, Chanaka Cooray <[email protected]> >> wrote: >> >>> Hi, >>> Is there are any way to initialize the endpoint? I used the same code as >>> the [1] and [2]. I modified the inbound endpoint section in the >>> carbon-mediation. >>> >>> [1] >>> https://github.com/wso2-dev/carbon-mediation/blob/master/components/inbound-endpoints/org.wso2.carbon.inbound.endpoint/src/main/java/org/wso2/carbon/inbound/endpoint/protocol/file/FileInjectHandler.java >>> >>> [2] >>> https://github.com/wso2-dev/carbon-mediation/blob/master/components/inbound-endpoints/org.wso2.carbon.inbound.endpoint/src/main/java/org/wso2/carbon/inbound/endpoint/protocol/jms/JMSInjectHandler.java >>> >>> My implementation for the invoke method as follows, I think problem with >>> that >>> >>> public boolean invoke(MqttMessage mqttMessage) { >>>> >>>> try { >>>> >>>> org.apache.synapse.MessageContext msgCtx = >>>>> createMessageContext(); >>>> >>>> String contentType = null; >>>> >>>> if (log.isDebugEnabled()) { >>>> >>>> log.debug("Processed MQTT Message of Content-type : " + >>>>> contentType); >>>> >>>> } >>>> >>>> MessageContext axis2MsgCtx = >>>>> ((org.apache.synapse.core.axis2.Axis2MessageContext) msgCtx) >>>> >>>> .getAxis2MessageContext(); >>>> >>>> // Determine the message builder to use >>>> >>>> Builder builder; >>>> >>>> if (contentType == null) { >>>> >>>> log.debug("No content type specified. Using SOAP >>>>> builder."); >>>> >>>> builder = new SOAPBuilder(); >>>> >>>> } else { >>>> >>>> int index = contentType.indexOf(';'); >>>> >>>> String type = index > 0 ? contentType.substring(0, >>>>> index) : contentType; >>>> >>>> builder = BuilderUtil.getBuilderFromSelector(type, >>>>> axis2MsgCtx); >>>> >>>> if (builder == null) { >>>> >>>> if (log.isDebugEnabled()) { >>>> >>>> log.debug("No message builder found for type '" >>>>> + type >>>> >>>> + "'. Falling back to SOAP."); >>>> >>>> } >>>> >>>> builder = new SOAPBuilder(); >>>> >>>> } >>>> >>>> } >>>> >>>> OMElement documentElement = null; >>>> >>>> >>>> >>>> String message = mqttMessage.toString(); >>>> >>>> InputStream in = new AutoCloseInputStream(new >>>>> ByteArrayInputStream( >>>> >>>> message.getBytes())); >>>> >>>> documentElement = builder.processDocument(in, >>>>> contentType, axis2MsgCtx); >>>> >>>> >>>>> // Inject the message to the sequence. >>>> >>>> >>>>> msgCtx.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement)); >>>> >>>> if (injectingSeq == null || injectingSeq.equals("")) { >>>> >>>> log.error("Sequence name not specified. Sequence : " + >>>>> injectingSeq); >>>> >>>> return false; >>>> >>>> } >>>> >>>> SequenceMediator seq = (SequenceMediator) >>>>> synapseEnvironment.getSynapseConfiguration() >>>> >>>> .getSequence(injectingSeq); >>>> >>>> seq.setErrorHandler(onErrorSeq); >>>> >>>> if (seq != null) { >>>> >>>> if (log.isDebugEnabled()) { >>>> >>>> log.debug("injecting message to sequence : " + >>>>> injectingSeq); >>>> >>>> } >>>> >>>> if(!synapseEnvironment.injectInbound(msgCtx, seq, >>>>> sequential)){ >>>> >>>> return false; >>>> >>>> } >>>> >>>> } else { >>>> >>>> log.error("Sequence: " + injectingSeq + " not found"); >>>> >>>> } >>>> >>>> >>>> >>>> } catch (Exception e) { >>>> >>>> log.error("Error while processing the MQTT Message"); >>>> >>>> } >>>> >>>> return true; >>>> >>>> } >>>> >>>> >>> On Mon, Jan 12, 2015 at 11:08 AM, Awanthika Senarath <[email protected] >>> > wrote: >>> >>>> Hi Chanaka, >>>> >>>> It appears as if the address endpoint you are directing the messages to >>>> is not in a working state. Please verify whether the endpoint is >>>> intialized. >>>> >>>> " java.lang.IllegalStateException: not initialized, endpoint must be >>>> in initialized state " >>>> >>>> the error is thrown from line 237 at [1] due to the endpoint not being >>>> initialized. >>>> >>>> [1] >>>> https://github.com/wso2/platform/blob/master/dependencies/synapse/2.1.1-wso2v8/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java >>>> >>>> thanks and regards >>>> Awanthika >>>> >>>> On Mon, Jan 12, 2015 at 10:53 AM, Malaka Silva <[email protected]> wrote: >>>> >>>>> Hi, >>>>> >>>>> Please compare your code with [1] >>>>> >>>>> This seems to be working. >>>>> >>>>> [1] >>>>> https://github.com/wso2-dev/carbon-mediation/blob/master/components/inbound-endpoints/org.wso2.carbon.inbound.endpoint/src/main/java/org/wso2/carbon/inbound/endpoint/protocol/file/FileInjectHandler.java >>>>> >>>>> On Mon, Jan 12, 2015 at 10:12 AM, Malaka Silva <[email protected]> >>>>> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> Please provide more details for this? >>>>>> >>>>>> Fro which point are you going to inject the message? >>>>>> >>>>>> Did you create the endpoint used in the send mediator? >>>>>> >>>>>> On Mon, Jan 12, 2015 at 9:56 AM, Chanaka Cooray <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Hi, >>>>>>> I need to inject a message to a esb sequence, I already wrote a java >>>>>>> code to implement that. When I created a sequence to send message to an >>>>>>> endpoint, the console indicates the following error. But when I tried to >>>>>>> inject the message to a sequence with log mediator, it works fine. >>>>>>> >>>>>>> [2015-01-12 09:37:26,679] ERROR - Axis2SynapseEnvironment Unexpected >>>>>>>>> error executing task/async inject >>>>>>>> >>>>>>>> java.lang.IllegalStateException: not initialized, endpoint must be >>>>>>>>> in initialized state >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.endpoints.AbstractEndpoint.readyToSend(AbstractEndpoint.java:244) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:54) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:80) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.filters.InMediator.mediate(InMediator.java:61) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:80) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:135) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectInbound(Axis2SynapseEnvironment.java:324) >>>>>>>> >>>>>>>> at >>>>>>>>> org.wso2.carbon.inbound.endpoint.protocol.mqtt.MQTTInjectHandler.invoke(MQTTInjectHandler.java:94) >>>>>>>> >>>>>>>> at >>>>>>>>> org.wso2.carbon.inbound.endpoint.protocol.mqtt.MqttListenerCallback.messageArrived(MqttListenerCallback.java:30) >>>>>>>> >>>>>>>> at >>>>>>>>> org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:332) >>>>>>>> >>>>>>>> at >>>>>>>>> org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:144) >>>>>>>> >>>>>>>> at java.lang.Thread.run(Thread.java:745) >>>>>>>> >>>>>>>> [2015-01-12 09:37:26,683] WARN - Axis2SynapseEnvironment Executing >>>>>>>>> fault handler due to exception encountered >>>>>>>> >>>>>>>> [2015-01-12 09:37:26,683] WARN - FaultHandler ERROR_CODE : 0 >>>>>>>> >>>>>>>> [2015-01-12 09:37:26,683] WARN - FaultHandler ERROR_MESSAGE : not >>>>>>>>> initialized, endpoint must be in initialized state >>>>>>>> >>>>>>>> [2015-01-12 09:37:26,684] WARN - FaultHandler ERROR_DETAIL : >>>>>>>>> java.lang.IllegalStateException: not initialized, endpoint must be in >>>>>>>>> initialized state >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.endpoints.AbstractEndpoint.readyToSend(AbstractEndpoint.java:244) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:54) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:80) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.filters.InMediator.mediate(InMediator.java:61) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:80) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:135) >>>>>>>> >>>>>>>> at >>>>>>>>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectInbound(Axis2SynapseEnvironment.java:324) >>>>>>>> >>>>>>>> at >>>>>>>>> org.wso2.carbon.inbound.endpoint.protocol.mqtt.MQTTInjectHandler.invoke(MQTTInjectHandler.java:94) >>>>>>>> >>>>>>>> at >>>>>>>>> org.wso2.carbon.inbound.endpoint.protocol.mqtt.MqttListenerCallback.messageArrived(MqttListenerCallback.java:30) >>>>>>>> >>>>>>>> at >>>>>>>>> org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:332) >>>>>>>> >>>>>>>> at >>>>>>>>> org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:144) >>>>>>>> >>>>>>>> at java.lang.Thread.run(Thread.java:745) >>>>>>>> >>>>>>>> >>>>>>>>> [2015-01-12 09:37:26,684] WARN - FaultHandler ERROR_EXCEPTION : >>>>>>>>> java.lang.IllegalStateException: not initialized, endpoint must be in >>>>>>>>> initialized state >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> The java code attached below is the code that I implemented to >>>>>>> inject the message into the sequence. >>>>>>> >>>>>>> >>>>>>>> *OMElement documentElement = null;* >>>>>>>> * InputStream in = new AutoCloseInputStream(new >>>>>>>> ByteArrayInputStream(* >>>>>>>> * message.getBytes()));** >>>>>>>> documentElement = builder.processDocument(in, contentType, >>>>>>>> axis2MsgCtx);* >>>>>>>> >>>>>>>> * // Inject the message to the sequence.* >>>>>>>> * >>>>>>>> msgCtx.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));* >>>>>>>> * if (injectingSeq == null || injectingSeq.equals("")) {* >>>>>>>> * log.error("Sequence name not specified. Sequence : >>>>>>>> " + injectingSeq);* >>>>>>>> * return false;* >>>>>>>> * }* >>>>>>>> * SequenceMediator seq = (SequenceMediator) >>>>>>>> synapseEnvironment.getSynapseConfiguration()* >>>>>>>> * .getSequence(injectingSeq);* >>>>>>>> * seq.setErrorHandler(onErrorSeq);* >>>>>>>> * if (seq != null) {* >>>>>>>> * if (log.isDebugEnabled()) {* >>>>>>>> * log.debug("injecting message to sequence : " + >>>>>>>> injectingSeq);* >>>>>>>> * }* >>>>>>>> * if(!synapseEnvironment.injectInbound(msgCtx, seq, >>>>>>>> sequential)){* >>>>>>>> * return false;* >>>>>>>> * }* >>>>>>>> * } else {* >>>>>>>> * log.error("Sequence: " + injectingSeq + " not >>>>>>>> found");** }* >>>>>>> >>>>>>> >>>>>>> Is there are any way to fix this error? >>>>>>> Thank You >>>>>>> -- >>>>>>> *Chanaka Sampath Cooray* >>>>>>> Software Engineering Intern, >>>>>>> WSO2 Lanka (pvt) Ltd. >>>>>>> Mobile:+94713614884 >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> >>>>>> Best Regards, >>>>>> >>>>>> Malaka Silva >>>>>> Senior Tech Lead >>>>>> M: +94 777 219 791 >>>>>> Tel : 94 11 214 5345 >>>>>> Fax :94 11 2145300 >>>>>> Skype : malaka.sampath.silva >>>>>> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77 >>>>>> Blog : http://mrmalakasilva.blogspot.com/ >>>>>> >>>>>> WSO2, Inc. >>>>>> lean . enterprise . middleware >>>>>> http://www.wso2.com/ >>>>>> http://www.wso2.com/about/team/malaka-silva/ >>>>>> <http://wso2.com/about/team/malaka-silva/> >>>>>> >>>>>> Save a tree -Conserve nature & Save the world for your future. Print >>>>>> this email only if it is absolutely necessary. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> >>>>> Best Regards, >>>>> >>>>> Malaka Silva >>>>> Senior Tech Lead >>>>> M: +94 777 219 791 >>>>> Tel : 94 11 214 5345 >>>>> Fax :94 11 2145300 >>>>> Skype : malaka.sampath.silva >>>>> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77 >>>>> Blog : http://mrmalakasilva.blogspot.com/ >>>>> >>>>> WSO2, Inc. >>>>> lean . enterprise . middleware >>>>> http://www.wso2.com/ >>>>> http://www.wso2.com/about/team/malaka-silva/ >>>>> <http://wso2.com/about/team/malaka-silva/> >>>>> >>>>> Save a tree -Conserve nature & Save the world for your future. Print >>>>> this email only if it is absolutely necessary. >>>>> >>>>> _______________________________________________ >>>>> Dev mailing list >>>>> [email protected] >>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>> >>>>> >>>> >>>> >>>> -- >>>> Awanthika Senarath >>>> Software Engineer, WSO2 Inc. >>>> Mobile: +94717681791 >>>> >>>> >>>> >>> >>> >>> -- >>> *Chanaka Sampath Cooray* >>> Software Engineering Intern, >>> WSO2 Lanka (pvt) Ltd. >>> Mobile:+94713614884 >>> >> >> >> >> -- >> Awanthika Senarath >> Software Engineer, WSO2 Inc. >> Mobile: +94717681791 >> >> >> > > > -- > *Chanaka Sampath Cooray* > Software Engineering Intern, > WSO2 Lanka (pvt) Ltd. > Mobile:+94713614884 > -- *Chanaka Sampath Cooray* Software Engineering Intern, WSO2 Lanka (pvt) Ltd. Mobile:+94713614884
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
