Is it possible to send JMS Messages to a JMS Queue in Message Broker to be further processed by a Message Processor without a Message Store?
e.g.
<resource methods="PUT" uri-template="/{itemName}">
<inSequence>
<property name="transport.jms.ContentTypeProperty" value="Content-Type" scope="axis2"/>
<property name="HTTP_METHOD" expression="get-property('axis2','HTTP_METHOD')" scope="transport" type="STRING"></property>
<property expression="json-eval($.barcode)" name="uri.var.barcode" scope="default" type="STRING"/>
<log level="full">
<property expression="get-property('uri.var.barcode')" name="barcode"/>
</log>
<payloadFactory media-type="json">
<format>
{"barcode": "$1"}
</format>
<args>
<arg evaluator="xml" expression="get-property('uri.var.barcode')"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address uri="jms:/myqueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=conf/jndi.properties&transport.jms.DestinationType=queue&transport.jms.ContentTypeProperty=ContentType"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
</resource>
Say I have a simple API that received a JSON body and I want to send it to a queue called myqueue, I would like a Message Processor to read the messages for further processing.
Or perhaps is there some other way to achieve a similar concept?
If your requirement is merely to consume messages from a particular queue for further processing, the following could be a better fit rather than message processors, which have been designed to be used with message stores storing messages temporarily:
JMS Inbound Endpoints (https://docs.wso2.com/display/EI611/Sample+901%3A+Inbound+Endpoint+JMS+Protocol+Sample)
JMS Listener Proxy
(https://docs.wso2.com/display/EI611/The+ESB+Profile+of+WSO2+Enterprise+Integrator+as+a+JMS+Consumer)
Related
I have a REST service that returns a json simple {message: "ok"}. When I use Respond Mediator this stop further processing of a message and send the message back to the client.
I need to send response to client, and then execute task asynchronously, but if I use it ignores the next call to a sequence or an endpoint.
How can you respond synchronously (response to client) and then invoke a service, without response mediator ignore the next mediator?
thanks;
I was able to solve the challenge. effectively Clone mediator not just clone message, it give new separate life to new message.
<api xmlns="http://ws.apache.org/ns/synapse" name="porticApiAsyn" context="/test">
<resource methods="POST" url-mapping="/asyn">
<inSequence>
<log>
<property name="message" value="asyn"/>
</log>
<payloadFactory media-type="json">
<format>{"message":"asyn test"}</format>
<args/>
</payloadFactory>
<clone continueParent="true" sequential="true">
<target sequence="logSequence"/>
</clone>
<respond/>
</inSequence>
In this case, the message is sent to logsequence, then the response mediator is executed. Thanks for your help.
For your case you could even do the following
<api xmlns="http://ws.apache.org/ns/synapse" name="porticApiAsyn" context="/test">
<resource methods="POST" url-mapping="/asyn">
<inSequence>
<log>
<property name="message" value="asyn"/>
</log>
<payloadFactory media-type="json">
<format>{"message":"asyn test"}</format>
<args/>
</payloadFactory>
<clone continueParent="true" sequential="true">
<target sequence="logSequence"/>
<target>
<sequence>
<respond/>
</sequence>
</target>
</clone>
</inSequence>
I guess it should work as well and is maybe more readable
I am developing a proxy service with a soap webservice that performs soap to rest conversion, the message is sent to a servlet that response with a string in flat format (not xml), just a secuence of characters like
OIUW|ECHNOWE|RFHQWIUE|FBPQW|EFHAO|IEFH
I am invoking with SOAP UI and I get this response fine, now I would like to receive it in "SOAP format", wrapping the message into a soap:body, I've tried with a XSLT and with a PayloadFactory Mediator, but as soon as I use any of them (even doing nothing) I get a
[2014-07-31 09:30:41,847] ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
What do I do wrong ? How can I achieve a message transformation without this exception?
Thank you!
UPDATE: My proxy as requested by Ratha
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="SCL3"
transports="http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<log level="custom">
<property name="MyTrace" value="--- REQUEST ---"/>
</log>
<log level="full"/>
<property name="REST_URL_POSTFIX"
value="x4?msg=x4|0003|0000000021|0|0|0400002081020224849"
scope="axis2"
type="STRING"/>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
<property name="SOAPAction" scope="default" action="remove"/>
<header name="Action" scope="default" action="remove"/>
<send>
<endpoint>
<address uri="http://localhost:8087/X4" format="pox"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="custom">
<property name="MyTrace" value="--- RESPONSE ---"/>
</log>
<property name="ContentType"
value="application/soap+xml"
scope="transport"
type="STRING"/>
<property name="messageType"
value="application/soap+xml"
scope="transport"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<a xmlns="">$1</a>
</format>
<args>
<arg value="my value"/>
</args>
</payloadFactory>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:/C:/wso2/wso2esb-4.8.1/repository/workspaces/myproject/SCL3.wsdl"/>
</proxy>
I've seen that my servlet was setting content type to "text/xml" instead of "text/plain", I've changed it to "text/plain" and everything is working fine now.
Therefore I deduce that the error message
"Content is not allowed in prolog"
actually means
"Unexpected content type"
When you have following outsequence configuration what your log prints?
<outSequence>
<log level="full">
<property name="MyTrace" value="--- RESPONSE ---"/>
</log>
<send/>
</outSequence>
While I am using call out mediator in wso2 esb , with DSS Endpoint I am
getting the request only, I am not getting response, even I put log in
the out sequence. Here I am sending my proxy service.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Binaryformat"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="ContentType" value="application/json" scope="axis2"/>
<log level="full">
<property name="M1" value="*************Callout PROXY*************"/>
</log>
<callout serviceURL="http://192.168.1.201:9769/services/emp_DataService/">
<source type="envelope"/>
<target key="response"/>
</callout>
<log level="full">
<property name="Status" expression="get-property('response')"/>
</log>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true"/>
<!--<property name="OUT_ONLY" value="true"/>-->
<send/>
</inSequence>
<outSequence>
<log level="full">
<property name="Status" expression="get-property('response')"/>
</log>
<payloadFactory media-type="xml">
<format>
<response>outonly</response>
</format>
<args/>
</payloadFactory>
<property name="OUT_ONLY" value="true"/>
<send/>
</outSequence>
</target>
</proxy>
I think you have configured callout mediator wrongfully. Check for the callout mediator sample here
http://docs.wso2.org/display/ESB470/Sample+430%3A+Simple+Callout+Mediator+for+Synchronized+Web+Service+Invocation
As well as OUT-ONLY set to "true" mean on a message to indicate that no response message is expected for it once it is forwarded from the ESB. you can read more about OUT_ONLY and other properties from here http://docs.wso2.org/display/ESB470/Generic+Properties
callout mediator is synchronous, it will return the response in the same sequence (your inSequence, by doing a blocking call) : your outSequence is unnecessary.
however, you should add a faultSequence to log any error
you should use tcpmon (launch tcpmon in ESB_HOME/bin) between ESB and your endpoint to verify request content going to your service and verify if you obtain a response from your service.
I have a situation where in i have created a proxy service where in i have used an inline wsdl so that i can pass some data from try-it tool. After that i want to get the data passed from try-it to in seq that i am able to do.After that there is no use of inline-wsdl. In the "in-sequence" i have used a custom class mediator inside which i have set a property called "user" and i have saved that property value(user) in Property mediator. Now i want to send this property as response through out sequence.How to do this. Please help...
My Proxy code is:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="ProviderPublication" transports="https,http" statistics="disable" trace="disable" startOnLoad="false">
<target>
<inSequence>
<property xmlns:xs="http://www.openandaway.org/xml/BBC/" name="URI" expression="//xs:SessionID" scope="default" type="STRING"/>
<payloadFactory>
<format>
<p:Session xmlns:p="http://www.openandaway.org/xml/BBC/">
<xs:ChannelURI xmlns:xs="http://www.openandaway.org/xml/BBC/">$1</xs:ChannelURI>
</p:Session>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('URI')"/>
</args>
</payloadFactory>
<log level="full">
<property name="Inside_In_Sequence" value="---------Hi i am inside in sequence--------------"/>
</log>
<log level="full">
<property name="PropValFromURI" expression="get-property('URI')"/>
</log>
</inSequence>
<outSequence>
<log level="full">
<property name="Inside_Out_Sequence" value="-------Hi inside Out Sequence--------------------"/>
</log>
<property name="GetDataFromINSeq" expression="get-property('URI')" scope="default" type="STRING"/>
<log level="full">
<property name="GetPropValueFromInSeq" expression="get-property('URI')"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://10.224.188.87:2425/BBC1.0/services/BBCPublicationService?wsdl"/>
<description></description>
</proxy>
In the above code i am not able to get inside the out sequence. It is not hitting the out-sequence.Where am i doing wrong?
In your proxy's in-sequence, I dont see you sending the message to any backend. i.e. I dont see a send part in the in-sequence. Without the message going out, there is no way for a response to come to the out-sequence.
Regarding your original question on accessing properties set by your class mediator, if you set the property with the scope set to "synapse", you can access it within any place in your proxy.
You can access that property at the outsequence. Please refer following threads.
stWSO2ESB OutSequence Processing
Pass property from inSequence to outSequence
My current scenario is that i have a web service exposed from data service which returns me email address of the user when i give it the name of the user. Now i want to use this web service in ESB and get the email id from this web service in a property and show it in console using LOG mediator.
What should i do now and how?
Sorry for this silly question but i am newest member of wso2 esb. So please help me on this.
Now ihave a response like:
<brs:getRecipientKeyResponse xmlns:brs="http://brs.carbon.wso2.org">
<brs:MailRecipient xsi:type="ax2338:MailRecipient" xmlns:ax2338="http://email.samples/xsd" xmlns:ax2337="http://email.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax2337:recipient>kevin</ax2337:recipient>
</brs:MailRecipient>
</brs:getRecipientKeyResponse>
Ihave to get the recipient element from this response and put this in payload. My complete sequence for this is:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="receiveSeq">
<log>
<property name="getRecipient" value="------------Trying to get data Fom BRS Response----------------------------"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ax2337="http://email.samples/xsd" name="Recipient" expression="//ax2337:recipient"/>
</log>
<payloadFactory>
<format>
<p:GetEmailDetails xmlns:p="http://ws.wso2.org/dataservice">
<xs:name xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:name>
</p:GetEmailDetails>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" xmlns:ax2337="http://email.samples/xsd" expression="//ax2337:recipient"/>
</args>
</payloadFactory>
<log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="getName" expression="get-property('Recipient')"/>
</log>
<send receive="DBSeq">
<endpoint key="emailServiceEP"/>
</send>
</sequence>
<!--this part is not able to get data --->
<property xmlns:ns="http://org.apache.synapse/xsd" name="getName" expression="get-property('Recipient')"/>
u just use the the your wso2dss tryit service in that request side code copy into the payloadfactory insted of " ? " keep the $1 ,$2 ..like this and pass the argument below as per ur above order order is play a vital role for this response i think it will help for u
<payloadFactory>
<format>
<p:insert_emp_operation xmlns:p="http://ws.wso2.org/dataservice">
<xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno>
<xs:ename xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:ename>
<xs:esal xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:esal>
</p:insert_emp_operation>
</format>
<args>
<arg expression="get-property('eno')"/>
<arg expression="get-property('ename')"/>
<arg expression="get-property('esal')"/>
</args>
</payloadFactory>
<send receive="Error_Seq">
<endpoint>
<address uri="http://localhost:9764/services/emp_DataService/" format="soap11"/>
</endpoint>
</send>
Since you have the Dataservice is implemented, give that as endpoint url to your proxy which can be created in wso2esb. When you send request to your proxy,in the outsequence, you will receive the response of your dataservice. Just do a log with "level=full" you will see the full response. Use the property mediator and do an xpath to pick the value which you needed.
Sample conf:
<proxy name="StockQuoteProxy">
<target>
<endpoint>
<address uri="DS endpoint"/>
</endpoint>
<outSequence>
<log level="full">
<property name="email" expression="xpath from the email attribute in the rseponse"/>
</log>
<send/>
</outSequence>
</target>
</proxy>
Here is esb sample guide on how to create proxies;
http://docs.wso2.org/wiki/display/ESB460/Proxy+Service+Samples