Asynchronous listeners , selectors using messageId

Hi,
Could anyone please advise on a recommended way to register an asynchronous message listener, using a message selector that relies on message id ?
I'm having a race condition, because message ID is only known after you've sent it; by that time, it's too late to register the listener since it may miss the reply.
Some tutorials suggest call connection.start() only after listener is registered, but due to performance reasons I'd rather have a single connection, started when application is started up.
Code example:
// Global, single connection, started on application startup (can't
// affort to re-open and re-start on each request).
QueueConnection con= ...
con.start();
// On request:
QueueSession s = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue= s.createQueue...
QueueSender sender = s.createSender();
Message msg=session.createTextMessage(); // jmsMsgId is null
sender.send(msg);  // now jmsMsgId is set
// -- Race condition time: reply may come before listener is registered
String selector="JMSCorrelationID=' + msg.getJmsMessageId() + "'";
QueueReceiver receiver = s.createReceiver(queue, selector);
receiver.setMessageListener( myListener);Thank you very much in advance :)
(A copy of this was also sent to the javaranch forum)

i meant:
QueueConnection con= ...
QueueSession s = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue= s.createQueue...
QueueSender sender = s.createSender();
QueueSession rcvSess = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
con.start();of course - in your example you can not create the receiver before the sending of the message, sorry for the misunderstanding, but setting up of the receiving session alone before actually sending can save time.
actually, i would probably set up the application differently.
i can't think of a real-world situation where what you are doing makes sense. you are practically creating a receiver + listener for one message only.
additionally, you create the receiver after the message is sent, and it is in the same application (because otherwise - how do you tell the other side what's the message id? if you can tell the other side what's the message id - you can just as well send it the message).
i wouldn't use a selector the way you did. i don't think you should use the JMSMessageId. If you must set something like this up - try using a property on the message that you'd set to a pre-known value, and use the selector with that.
if you want to elaborate on the problem you're trying to solve, i might be able to give a better answer..
nimo.

Similar Messages

  • Time of callback: Asynchronously receiving messages using a listener class

    I was developing a small JMS client that registers a message listener for receiving text messages from a JMS provider. The program is single threaded.
    I wanted to know when exactly the "onMessage" method is invoked for processing received messages. My client could be performing other processing tasks after registering the listener. In such a scenario, on arrival of a message, when does the program flow jump to the onMessage method? Is it as soon as a message arrives (in which case, the client could be abruptly interuptted in the midst of some processing/system call) ? If so, does the execution return to the exact point of interuption after the onMessage method returns? Or does the java runtime environment implicitly spawn a thread for processing the message?
    If the answer to my questions is the former, then does it mean that such clients are best written as multi threaded programs??
    Any pointers on this aspect would be greatly appreciated....

    Hi,
    Even if the JMS specification says that a session is single threaded, asynchronous messages are processed within their own thread. As a programmer (a JMS API user) you don�t have to worry about implementation details. The only thing you have to know is that:
    1) Your JMS server pushes messages to your asynchronous listeners upon availability
    2) Asynchronous messages are sequentially processed on the session level (concurrency is achieved by using several sessions)
    3) Using ExceptionListener allows a client application to be asynchronously notified of a problem (this is useful to do some cleaning or reconnection operations)
    I hope this helps
    Arnaud
    www.arjuna.com

  • Getting a message using messageID

    Hi all,
    I wanna use messageID to reach messages because the message no(relative order of the message) may change. It is ok to get messageID's of messages but I could not see any method to get a message from the server by messageID. Messages may be taken by UID or messageNo in JavaMail. Is it possible to get messages using MessageID's? Should I perform a searc based on messageID to get message?

    You need to remember that:
    1. Not all messages will have Message-IDs.
    2. Message-IDs are not guaranteed to be unique.
    While these situations are rare, you need to decide whether that's
    something that your application can handle.
    If you're using IMAP, you'll be much better off using UIDs.
    If you're using POP3, you'll also be much better off using UIDs.
    While an IMAP server can fairly efficiently search by Message-ID,
    when using POP3 all the message headers will need to be downloaded
    to the client and the search will be performed on the client, which is
    fairly expensive for large numbers of messages.

  • VRF selector using PBR or Source IP address

    Could anyone can tell which is the better choice of VRF selector using PBR or Source IP address? From Cisco doc, VRF selection based on Source take advance over PBR. My feeling is that PBR may match more criterias than just match source IP address.
    Thanks

    I would personally use the "VRF selection based on source IP address" only where the "VRF selection using PBR" is not available since the latter is a superset of the former.
    Hope this helps,

  • Example of Asynchronous Web Service Using Oracle APIs

    Greetings,
    Is there any tutorial, section or example of Oracle, that explains clearly, how to create an Asynchronous Web Service using Oracle APIs.
    Thakns in advance for your help.-

    Does this help:
    http://niallcblogs.blogspot.com/2009/03/calling-async-bpel-process-from-jdev.html

  • OSB -How to communicate with a Asynchronous SOAP Service using OSB

    Hi,
    I am new to OSB and I need some help in working with Asynchronous SOAP Service.
    Test Case : OSB --> Proxy Service --> Business Service-->External Service pointing to Asynchronous service WSDL.
    While testing the proxy service using sb console i don't get a response back.
    After some googling I found out the following:
    ->We need to create another Proxy service for listening to callback from that Asynchronous service.
    ->Setting the "WS-replyTo" in header variable while sending the initial request to Business Service(pointing to Asynch wsdl).
    Even after this I am not getting some response.
    Questions :
    1. Can someone let me know in detailed way(end to end) what has to be done to achieve this ?
    2. The Asynch wsdl exposes only one port in the <service> tag ie., which is haing the binding related to "process" operation. ( but not processCallback operation)
    So in this case how do i make my responseProxy service listen to callback port ? When I try to do I just see the process binding only.
    Thanks and Regards,
    Sridhar.

    Vernetto,
    I am not sure about the publish, but yes we can do this without JMS also. Please refer to this post which is quite helpful which routes back to a proxy service.
    http://eelzinga.wordpress.com/2010/03/23/oracle-service-bus-invoke-asynchronous-webservices/
    Regards,
    Sridhar.

  • Asynchronous RFC calling using BPM

    Hi to all,
    I have this scenario:
    FILE -> XI -> RFC -> XI
    I want to use the BPM to do this, thus I have built this BPM:
    START -> RECEIVE -> BLOCK1(SEND) -> BLOCK1(RECEIVE) -> STOP
    My problem is that I want to use an asynchronous scenario and, thus, when XI sends message to RFC, BPM seems to become inactive and the BPM is not able to receive the RFC Response. How can I solve this problem? How can I mantain BPM active to receive the RFC Response?
    Thanks to all!

    Hey,
    I suppose you are trying to do a similar senario
    The scenario must be executed asynchronously, but there needs to be an automatic confirmation that the business data was successfully processed (this would be the equivalent of an applicationacknowledgement). Cross-component BPM (ccBPM) will be used to process the confirmation message.
    How To… Use BAPI wrappers in asynchronous scenarios with ccBPM
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/59ef6011-0d01-0010-bfb0-b51381e00509
    <b>Cheers,
    *RAJ*
    *REWARD POINTS IF FOUND USEFULL*</b>

  • Implementation of Asynchronous Web Services using JDeveloper

    Various articles and tutorials, which I have read, are talking about asynchronous BPEL processes. These asynch BPEL processes are result of the orchestration of different synch and asynch atomic services (web services in specific). There are even tutorials as part of Oracle SOA Suite and JDeveloper explaining how to consume asynchronous services in a BPEL process. Well and good.
    But unfortunately I haven’t seen any tutorial or article talks about the implementation of asynchronous web services (How to implement an asynchronous service?). All what they talk about is the consumption side of it and the applicability of WS-Addressing or Correlation ID for the consumption of the Service.
    As part of my research, I delved further into the sample BPEL processes comes out with Oracle BPEL Process Manager. For example; I have had a look into the Asynchronous Loan Processor process, where it is orchestrating a Synch Credit Rating Service and three asynch services namely Star Loan, United Loan and American Loans. But as I delved down into those, I realized that these services are simply BPEL Processes where it is implemented as a sequence of Receive, Assign and Invoke activities, where each of the activities does the following.
    Receive -- Receives the request from the client
    Assign -- Does some manipulation on the Input variable and set the output variable
    Invoke -- Invokes the client back (call back)
    These kinds of asynch services are pretty fine to demonstrate theory.
    But if we put ourselves more into practical scenarios, where we invoke a service from some application and the result of that invocation shall happen after some time (minutes to hours) in the form of a callback. In that case we WON’T be able to realize the service simply by a simple BPEL Process, rather we will have to implement as a Web Service with two port types implemented, where one port type is for the request and another one for the callback.
    I do understand these kinds of services can be implemented using JAX-WS.
    Question Here: How I do it using Oracle JDeveloper and Oracle Application Server???
    If anyone have done it, the REAL implementation of ASYNCH Web Services *(NOT BY USING BPEL or BPEL Wrapper)* using JDeveloper to deploy on Oracle Application Server or on Oracle SOA Suite, please post the know-how. If someone else is interested in taking it forward, we can take it further together.
    -Sudheer
    P.S: I am NOT at all interested in theory, as I had enough. Here I don’t want to be Conceptual; rather I am talking about hands-on.

    Hi Sudheer,
    I am not sure if this will help you
    If you take Oracle SOA Suite Order Booking Tutorial and go to Chapter 5 Creating the CreditService Project ( http://download.oracle.com/docs/cd/B31017_01/core.1013/b28937/creditservice.htm ), you learn how to create a synchronous Web service from a WSDL file.
    If you take the wsdl and delete output and fault tags (you can see it below) and follow the steps you'll generate an asynchronous web service.
    The generated Java method will be a void method
    public class ValidateCreditCardImpl {
    public void verifyCC(CreditCard creditCard) {
    Inside this void method you can try to call to a Receive BPEL Activity.
    I hope this will be useful . Regards,
    J
    <definitions targetNamespace="http://www.globalcompany.com/ns/credit"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://www.globalcompany.com/ns/credit"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:types="http://www.globalcompany.com/ns/credit.xsd">
    <types>
    <schema targetNamespace="http://www.globalcompany.com/ns/credit.xsd"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
    <complexType name="CreditCard">
    <sequence>
    <element name="ccType" type="string"/>
    <element name="ccNum" type="string"/>
    </sequence>
    </complexType>
    <element name="CreditCard" type="types:CreditCard"/>
    <element name="valid" type="boolean"/>
    <element name="error" type="string"/>
    </schema>
    </types>
    <message name="CreditCardValidationRequestMessage">
    <part name="CreditCard" element="types:CreditCard"/>
    </message>
    <message name="CreditCardValidationResponseMessage">
    <part name="valid" element="types:valid"/>
    </message>
    <message name="CreditCardValidationFaultMessage">
    <part name="error" element="types:error"/>
    </message>
    <portType name="ValidateCreditCard">
    <operation name="VerifyCC">
    <input message="tns:CreditCardValidationRequestMessage"
    name="CreditCardInfo"/>
    </operation>
    </portType>
    <binding name="ValidateCreditCardSoapHttp" type="tns:ValidateCreditCard">
    <soap:binding style="document"
    transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="VerifyCC">
    <soap:operation soapAction="http://www.globalcompany.com/ns/credit/VerifyCC"/>
    <input name="CreditCardInfo">
    <soap:body use="literal" parts="CreditCard"/>
    </input>
    </operation>
    </binding>
    <service name="CreditService">
    <port name="ValidateCreditCardServiceSoapHttp"
    binding="tns:ValidateCreditCardSoapHttp">
    <soap:address location="http://localhost:8888/CreditService"/>
    </port>
    </service>
    </definitions>
    Edited by: user10262974 on 30-mar-2009 16:19

  • Report - EPM Member selector - using filter

    Hi ALL,
    I would like to ask a general question : everytime I try to use <CONTEXT> value (within the "Member Selector" in the "Report Editor"), the selection doesn't work, my filter doesn't work ! Why ?
    And then I obtain this error message :
    How does it work ? What's wrong with my selection ? Is there some prerequisites to use it ?
    Can someone help me on this, it's hard to find information regarding how to make reports !
    Thanks a lot !!!
    Karine

    Hi Roberto,
    Thank you for your answer ! But this note doesn't solve the problem !
    Would you mind trying this and tell me your results :
    Make a simple report :TIME in column, ENTITY in page and COSTCENTER in row.
    Then click on COSTCENTER, it opened the "EPM - Member Selector"
    The dimension COSTCENTER has a property called ENTITY, so I select "ENTITY", operator is "=", Values is "<CONTEXT>" and the High Values/Dimensions is "ENTITY"
    And after this selction I have nothing !
    (I insist on that point to be clear : There are 2 different ENTITY, the first is the property of the dimension COSTCENTER and the second is a dimension)

  • Consolidation of Descendant Selectors Using JavaScript

    QUESTION:  How does one use Javascript to apply a CSS rule to a descendant set of selectors?
    BACKGROUND
    With each <li> tag (shown) there is associated a unique <body> tag (not shown).  Further, each <li> tag is grouped together with other <li> tags under the same <div> tag (shown).  All tags involved in this rule are uniquely identified with an id attribute.  Obvious, perhaps, there will be a unique webpage for each <li> tag.
    By way of example, if I were writing the rule for the tag <li id="setting"> of a single page, I would write it as follows:
    body#bodysetting div#probablepast li#setting {
         background-color:#AAA;
         color:#000;
    Note that the id of the <body> tag in the above example was obtained by prepending the word body before the id of the <li> tag.
    OBJECTIVE: With there being so many <li> tags, I am thinking that I should write a JavaScript that would repeat the above pattern for each and every tag.
    PROPOSAL:  For the moment, I am considering placing the <div> tag identifiers in one array, the <li> tag identifiers in another array, and then creating still another array for the <body> tag identifiers by prepending the word body to each element of the <li> tag array. A set of loop statements would then concatenate the tags and identifiers for each <li> tag into a single set of descendant selectors such as I have provided above and generate the same CSS rule for each new page when it opens.
    DISCLAIMER:  I realize that it would be sufficient to simply use the id of each <li> tag, but I would like to preserve the above structure for the sake of logical coherence and in anticipation of other behaviors that I have yet to develop.
    THE SELECTORS
    div#probablepast
    li#setting
    li#resistance
    li#ideology
    li#containment
    li#reforms
    li#deception
    div#popularpresent1
    li#peaceful
    li#industrious
    li#studious
    li#polite
    li#difficult
    li#closed
    li#traditional
    li#unique
    div#popularpresent2
    li#authoritarian
    li#mercantilist
    li#hightrust
    li#collective
    li#ricevillage
    li#neurotic
    li#racialpurity
    div#bridgingthegap
    li#gap
    li#identity
    li#shadows
    li#dilemma
    li#moreunique
    div#contemporaryjapan
    li#auntmadoka
    li#chishiki
    li#instruction
    li#worldwithin
    li#pyrimidal
    li#gaijinsama
    div#overcomingthebarriers
    li#culture
    li#genes
    li#nationalidentity
    li#bordercrossing
    li#language

    Murray *ACE* wrote: I am confused as to why you would want to style each list element uniquely.  It obviously is something of great importance (although I cannot think of an instance where I would want to do such a thing).
    With a little help you probably can:
    body#bodysetting li#setting {style definition}
    and
    li#setting {style definition}
    are not the same when the page is constantly changing as it does with "persistent page indicators".
    Murray *ACE* wrote: In that case, using javascript to accomplish something of great importance is a risky thing to do....
    Yes and no.  My Google stats tell me that 97% of my viewers are using Javascript when they view my pages.  This is an extraordinarily high proportion that is well worth targeting.  I can dream about the luxury of 100% accessibility after I begin receiving my expected book royalties. 
    For some, being generous is a way of life.  For others, it is a way of making a name for themselves while engaging in legalized tax evasion.  For me, it is a feeling that ebbs and flows according to the behavior of those who stand to benefit from my generosity.
    Thank you for your continued interest.
    Roddy

  • Multi Row Selector using Generic Column Names (parse query at runtime only)

    Hi,
    I created a tabular report which had a multi row select in it - got the deleting working fine.
    Am now creating a second tabular report, but because of the SQL:
    select
    "ID",
    "ID" ID_DISPLAY,
    "RESNUMBER",
    "RESDESCRIPTION",
    decode(RESTYPE,'R','Right Party','W','Wrong Party'),
    decode(DMCFLAG,'Y','Yes','N','No'),
    decode(SALEFLAG,'Y','Yes','N','No')
    from "CALL_RESULTS"
    I have to select the option Use Generic Column Names (parse query at runtime only) otherwise I cannot save the form.
    My problem is I am now unable to add a multi row selector to the tabular form. If I do and run the form I get the following error - failed to parse SQL query: ORA-00904: "COL11": invalid identifier. Also when I go back and edit the form the multi row selector has been removed.
    Can anyone tell me why I can't add a row selector like I previously could?
    Regards
    Simon

    Arie,
    I added aliases and to the decode columns, and I can now add a row selector to the form without any problems.
    Thank you very much for your help.
    Regards
    Simon

  • SAP XI Acknowledgements in asynchronous communication without using BPM.

    Hello experts,
    My scenario is File (Legacy system) -> XI->IDOC & I need to send the acknowledgement back to legacy system. How SAP XI acknowledgements work in asynchronous scenarios without a BPM process. I know it has to do something with ALEAUDIT. It would be great if someone describes how exactly it works?
    Regards,
    Nidhi

    Hi Nidhi,
    execute report IDX_ALEREQUEST on your PI system.
    - put for sender port the IDX1 port to your SAP system,
    - put the client of the SAP system
    - put the value of the SAP field "receiver partner number" (look at WE02)
    - put the value of the SAP field "receiver partner type"
    - put optional partner role
    The ALEAUD what the SAP ERP sends back (to be scheduled) will be handled at PI as seperate message. So you can do what ever you want with it, for example route it to an FTP server and map the values as you wish to have them.
    Regards,
    Udo

  • How to get  source payload using MessageID during runtime

    Hi Friends
    I have a requirement to re-process a successful message from PI as we are receiving  an error in its application acknowledgment . For this we are planning to take the source payload of that successful message (for which application acknowledgment is erroneous) and planning to reprocess that as a file again. For this we are in a need to get the source payload using the Message ID, If we have the parent message ID how can I get the source payload of that successful message.

    Hi Suman,
    Your requirement is not very clear to me. But whatever i understood is that you need source payload.
    You can go to sxmb_moni transaction and double click on your message (you can got your message either by date and time filter or by checking the namespace and sender and receiver interfaces)
    Inside message at left hand pane you can see XML message -> inbound message-> payloads
    Inside payload you will find main document. Now here you can see source xml. Right click on the xml and select view source and copy it.
    I hope it helps. Let me know if something is unclear
    Regards,
    Shradha

  • Is it possible to call asynchronous Web Service using Adaptive WS model?

    Hello,
    I was trying to call asynchronous web service and after execution exception has arised
    java.lang.NullPointerException
        at com.sap.tc.webdynpro.model.webservice.model.WSGenericModelClassExecutable.fillOutputParametersToMc(WSGenericModelClassExecutable.java:281)
        at com.sap.tc.webdynpro.model.webservice.model.WSGenericModelClassExecutable.execute(WSGenericModelClassExecutable.java:93)
        at com.sap.tc.webdynpro.model.webservice.gci.WSTypedModelClassExecutable.execute(WSTypedModelClassExecutable.java:46)
        at at.gov.bmf.demo.comp.employee.EmployeeDemo.ok(EmployeeDemo.java:242)
        at at.gov.bmf.demo.comp.employee.wdp.InternalEmployeeDemo.ok(InternalEmployeeDemo.java:285)
    I have NWDS 7.0.
    How can I set model, to avoid binding web service response to model?
    Thanks.

    I just ran into this issue, same exact problem.
    The quick and dirty workaround I did, after trying out several other things to make sure I didn't do anything wrong to cause this problem, was to just catch the nullpointer, and then go along my merry way.
    try{
         query.execute();     
    catch(NullPointerException e){
         //we get a worthless error here from Webdynpro, so we just ignore it. Not pretty. But unavoidable
    If someone else has any other solution, I would love to hear them.
    This is on NW7.0 SP15
    /Björn

  • Asynchronous communication using HSDIO

    All-
    I am trying to create an application for asynchronous serial communication using a PXI-6541 HSDIO card.  I have one RX and one TX line to/from the device I'm trying to communicate with. The device uses 25-bit words with the first 3 bits representing "labels" or commands.  There are only 7 labels that can be transmitted to the device and 2 that the it uses in response.  I currently have a sniffer set up so I can monitor the 2-way communication.  I am oversampling the data in WDT for viewing purposes but I am having a hard time extracting the data into something useable.  Has anyone used HSDIO for asynchronous communicaton and if so, can you send me some examples on how you triggered the data?  
    The serial bus is similar to Arinc429 http://en.wikipedia.org/wiki/ARINC_429 if that helps.  Any suggestions are appreciated.  
    Thank you!
    -Jason

    I was wondering, have you taken a look at the built-in examples under LabVIEW»Help»Find Examples»Browse»Hardware Input and Output»Modular Instruments»NI-HSDIO (High-Speed Digital I/O)? Under the Demo folder, there's one example called Dynamic Acquisition Hardware Start Trigger.vi. It has a pattern match start trigger option. 
    Just a thought...
    Nathan S.
    Applications Engineer
    National Instruments

Maybe you are looking for