J2EE.6.6 One JMS session per connection and code portability

Hello,
Section J2EE.6.6 of the J2EE 1.4 spec states that "Application
components in the web and EJB containers must not attempt to
create more than one active (not closed) Session object per connection."
This is contrary to the API documentation for javax.jms.Connection that
states "Because the creation of a connection involves setting up
authentication and communication, a connection is a relatively
heavyweight object. Most clients will do all their messaging with a
single connection." (Indeed I found that e.g. JBoss creates seven
threads for each connection that I create in a client).
I want to provide a library that encapsulates the required calls to
setup several JMS sessions. Given the above, this library must act
differently when run within and outside an EJB container. Is there a
portable way to determine in one's code whether the code is running
inside or outside an EJB container?
Regards,
Michael Lipp

Thanks very much for your responses. You miss, however, a very important point. Maybe I didn't emphasize this point enough in my original posting.
I want to write a client library with a "SomeServiceFactory" that creates a "SomeService". "SomeService" happens to require several concurrent topic sessions. But this requirement is to be hidden from the user of the service. And the supplied library should be usable both in a "client container" (i.e. a stand-alone client) and in an EJB or web container (with an EJB or Servlet making use of "SomeService").
So "SomeService" must behave differently when creating sessions, depending on whether it runs in the client container or an EJB or web container. Of course I can request the user/developer to specify some configuration file/option depending on the environment -- and then I can pray not to get too much problem reports because developers will simply forget to specify the environment as required or get things wrong.
Or I can find a way to automatically find out about the environment my library is used in and everybody is happy -- hence my original question.

Similar Messages

  • I just got the iPhone 5s, I have had a 4 for the last few years, my husband uses a galaxy.  I have never had issues with any of our phones connecting the the cars Bluetooth until this one sometimes it will connect and sometimes it won't.  I drive a gm car

    I just got the iPhone 5s, I have had a 4 for the last few years, my husband uses a galaxy.  I have never had issues with any of our phones connecting to the cars Bluetooth until this one sometimes it will connect and sometimes it won't.  I drive a gm car.  A friend of mine drives an Acura and said she is also having the same problem?  I have to connect the phone every time I get in the car. 

    Turn Off BT on your Phone & ReBoot..
    Delete the phone from the vehicles memory..
    Restart the Vehicle & go thro' the Pair set up..........

  • C4580 All-In-One suddenly lost wireless connection and I can't get it back.

    I have a replacement C4580 after HP replaced the old one because of their dmaned regionalisation of printers.
    It has been working fine through my wireless router, and I have been able to use it wirelessly on 2 different laptops, one running  XP and the other running Win 7. both have the printer showing as USB and wirless, normally being used wirelessly. THhe USB is there 'just in case' like now apparently.
    It seems that my wireless printer has disappeared from my Printers and Faxes in the XP machine, so I try to add it again. Can't detect any printers, so when it asks to be connected via USB it appears to be going through the setup, then I get Error #201 VSA.
    Googled for an answer but haven't found anything useful. Seen a couple which suggest that the router is hiding the SSID (it's not) or that MAC filtering is being used. Again, it's not.
    I went to the Win7 machine, and it shows the wireless and USB printers (2 versions of the same thing) but when I attempt to print a test page tot the wireless version, it says that it has been sent, and I can see it in the printer queue, but after a while I get Error-Printing which in typical HP software is as usual bloody useless as it doesn't tell you why it failed, or where to even start looking to correct whatever error there was.
    I have altered nothing on any of the computers (knowingly, anyway) and both laptops communicate quite happily with the outside world through the wirless router.
    I really am getting rather pi**ed off with HP and their latest software. I had a PSC 1210 prior to this and no problems with it at all. The hardware seems fine but the latest software leaves a lot to be desired.
    Any ideas anyone, on what has happened here, and how it can be fixed - or do I just cut my losses and buy another printer, this time anything but HP - unless they're all doing the same sort of stuff.
    I have tried turning the wireless function off and then on on the printer, but also no difference.
    Additional info. As suggested in another post somewhere, I have done both a Network Configuration and a Wireless Network Test printout. The test report shows PASS against both Wireless On and Wireless Working, and FAIL against Network Name (SSID) Found, but then shows the Network Name (SSID) correctly under Configuration Summary!
    The configuration page shows Netwok Status as offline, and under 802.11 Wireless it gives a MAc address then Status as Disabled.
    I don't really know what it is trying to tell me?
    Oh, accidentally I printed 2 Configuration pages. On one it says that the 802.11 Status is Disabled and on the other it says that it is Disconnected. Unfortunately, I don't know which one was done first. The Disconnected one may have been done when I turned the wireless off. Nope, I just did again with Wireless turned on (at least the light is showing) and it still showing as Disconnected.

    Hi there KR,
    Sorry to hear the reset is not working for you on your PS C4580. The steps for the reset are all correct and should have worked if the printer is in good functioning order.
    I would suggest calling in to HP directly to see what your options are with them.
    If you decide to call them, this is their contact info:
    If you are calling within North America, the number is 1-800-474-6836 and for all other regions: click here.
    Have a great Tuesday
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • The pooled JMS session is enlisted in another transaction error

    I have an MDB with pool size 2 deployed in weblogic 9.2.3(linux). I see the following error in server logs.
    <May 27, 2009 7:32:26 AM CDT> <Error> <EJB> <BEA-010079> <An error occurred while attempting to receive a message from JMS for processing by a message-driven bean: javax.jms.JMSException: [J2EE:160054]The pooled JMS session is enlisted in another transaction and may not be used elsewhere
    The exception is : javax.jms.JMSException: [J2EE:160054]The pooled JMS session is enlisted in another transaction and may not be used elsewhere
         at weblogic.deployment.jms.JMSExceptions.getJMSException(JMSExceptions.java:22)
         at weblogic.deployment.jms.WrappedTransactionalSession.enlistInTransaction(WrappedTransactionalSession.java:196)
         at weblogic.deployment.jms.WrappedMessageConsumer.receive(WrappedMessageConsumer.java:198)
         at weblogic.ejb.container.internal.JMSMessagePoller.processOneMessage(JMSMessagePoller.java:297)
         at weblogic.ejb.container.internal.JMSMessagePoller.pollContinuously(JMSMessagePoller.java:394)
         at weblogic.ejb.container.internal.JMSMessagePoller.pollForParent(JMSMessagePoller.java:517)
         at weblogic.ejb.container.internal.JMSMessagePoller.run(JMSMessagePoller.java:533)
         at java.lang.Thread.run(Thread.java:595)
    >
    any idea why this error is coming??

    Looks it is like a bug, you can ask patch for from support.

  • How to pass data from one internal session to another

    Hi SAP Experts,
    How to pass data from one internal session to another and from One external session to another external session. I used import and export parmeter and SPA/GPA parameters. What is the other way to pass data?
    Please tel me urgently
    Thank you
    Basu

    Memory Structures of an ABAP Program
    In the Overview of the R/3 Basis System you have seen that each user can open up to six R/3 windows in a single SAPgui session. Each of these windows corresponds to a session on the application server with its own area of shared memory.
    The first application program that you start in a session opens an internal session within the main session. The internal session has a memory area that contains the ABAP program and its associated data. When the program calls external routines (methods, subroutines or function modules) their main program and working data are also loaded into the memory area of the internal session.
    Only one internal session is ever active. If the active application program calls a further application program, the system opens another internal session. Here, there are two possible cases: If the second program does not return control to the calling program when it has finished running, the called program replaces the calling program in the internal session. The contents of the memory of the calling program are deleted. If the second program does return control to the calling program when it has finished running, the session of the called program is not deleted. Instead, it becomes inactive, and its memory contents are placed on a stack.
    The memory area of each session contains an area called ABAP memory. ABAP memory is available to all internal sessions. ABAP programs can use the EXPORT and IMPORT statements to access it. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.
    All ABAP programs can also access the SAP memory. This is a memory area to which all sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters are often used to preassign values to input fields. You can set them individually for users, or globally according to the flow of an application program. SAP memory is the only connection between the different sessions within a SAPgui.
    The following diagram shows how an application program accesses the different areas within shared memory:
    In the diagram, an ABAP program is active in the second internal session of the first main session. It can access the memory of its own internal session, ABAP memory and SAP memory. The program in the first internal session has called the program which is currently active, and its own data is currently inactive on the stack. If the program currently active calls another program but will itself carry on once that program has finished running, the new program will be activated in a third internal session.
    Data Clusters in ABAP Memory
    You can store data clusters in ABAP memory. ABAP memory is a memory area within the internal session (roll area) of an ABAP program and any other program called from it using CALL TRANSACTION or SUBMIT.
    ABAP memory is independent of the ABAP program or program module from which it was generated. In other words, an object saved in ABAP memory can be read from any other ABAP program in the same call chain. ABAP memory is not the same as the cross-transaction global SAP memory. For further information, refer to Passing Data Between Programs.
    This allows you to pass data from one module to another over several levels of the program hierarchy. For example, you can pass data
    From an executable program (report) to another executable program called using SUBMIT.
    From a transaction to an executable program (report).
    Between dialog modules.
    From a program to a function module.
    and so on.
    The contents of the memory are released when you leave the transaction.
    To save data objects in ABAP memory, use the statement EXPORT TO MEMORY.
    Saving Data Objects in Memory
    To read data objects from memory, use the statement IMPORT FROM MEMORY.
    Reading Data Objects from Memory
    To delete data clusters from memory, use the statement FREE MEMORY.
    Deleting Data Clusters from Memory
    please read this which provide more idea about memory
    Message was edited by:
            sunil kumar

  • ITunes keeps popping up fr no reason with nothing connected and it is driving me insane, any suggestions?

    iTunes keeps popping up for no reason with nothing connected and it is driving me insance, any suggestion?
    I have tried rebooting and this hasnt helped.

    vivianalozano wrote:
    I assume that a neighbour has an iphone that tries to sync to my itunes repeteadly making the window pop up every 5 minutes...
    That really is not likely since the device would have to have at one time been physically connected and synced to your computer, AND Wi-Fi sync enabled while connected to your library, AND they'd have to be on your Wi-Fi network.  Unless you have someone who did all this and lives within Wi-Fi range, and knows your network password, that's not what's happening.
    Do you have any auxillary software add-ons to iTunes (e.g. Last.fm scrobbler)?  Sometimes those get in the way of shutting iTunes down and it will re-open unless you shut the other software down first.

  • Lion Server Admin, Server, connection and authentication issues.

    I'm going out of my mind... I'd appreciate any help
    Mac OS X Server 10.7.2
    Mac Mini Server (no optical drive.  dual hard drives) 2.66 C2D / 4GB RAM
    So... I open Workgroup Manager, select menu: Server > Connect.  Then Enter:
    Address = Server.local
    User Name = Server Administrator
    and my password.
    Press the Connect button and it successfully opens the Workgroup Manager window and I can edit users etc. all perfecty fine.
    I can also confirm that the Server Administrator user has "administer this server" ticked on.
    Now the trouble begins...
    I open Server (ie. the new Lion Server application).
    It shows me the "Choose a Mac" window.  Two entries:
    1. "This Mac - Server"
    2. "Other Mac"
    I click the first entry & it slides down the sheet for entering username and password.  I enter exactly the same details as above and the sheet shakes left and right, essentially behaving as if I'd entered the wrong password.  Despite the fact that it's the same password as above.
    I try it from another machine as well, just to be sure, and I get the same result.
    Then I open Server Admin.
    At some point recently, I recall having essentially the same problem.  An attempt to connect to the server shook the authentication sheet essentially suggesting wrong password.
    More recently, Server.local now doesn't even show up in the Available Servers section.
    If I try Add Server from the Server menu. Then Enter the same details above I get a  "Could not connect..." message.
    So... I'm kinda baffled.  What on earth is going on?  The three different apps are telling me different things.  One works perfectly, one says it's running fine but I can't authenticate, and the other says it doesn't even exist.
    For what it's worth, I've tried using Workgroup Manager (the one thing that will connect and authenticate) to change/reset the password for the Server Administrator user, but no matter what I set it to I'm still getting all the same results as above.
    If anyone can give me any help here I'd be very grateful!!
    Thanks!
    David.

    Is there really no one who can help me with this? 

  • Why 9 connections are automatically created per one jms topic?

    Why 9 connections are automatically created per one jms topic?
    Is it possible for one topic to have one connection, rather nine connecions?
    If so, any drag concerning having one connection of one topic?
    Let me know asap, it would be really appreciated.
    <code>
    public void connectJMS() {
    try {
    if (RTConst.getInstance().getConnectMode() != RTConst.NOTCONNECT) {
    targetTCF = ServerDelegate.getTopicFactoryComm();
    targetT = ServerDelegate.getTopicNameComm();
    connection = targetTCF.createTopicConnection();
    session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    topicSubscriber = session.createSubscriber(targetT);
    topicSubscriber.setMessageListener(this);
    connection.start();
    System.out.println("[CommJMSReceiver] Common Topic Connection successed");
    } catch (Exception ex) {
    System.out.println("[CommJMSReceiver] Common Topic Connection failed");
    ex.printStackTrace();
    </code>
    Message was edited by:
    PaulSheldonII_Screen

    Why 9 connections are automatically created per one jms topic?
    Is it possible for one topic to have one connection, rather nine connecions?
    If so, any drag concerning having one connection of one topic?
    Let me know asap, it would be really appreciated.
    <code>
    public void connectJMS() {
    try {
    if (RTConst.getInstance().getConnectMode() != RTConst.NOTCONNECT) {
    targetTCF = ServerDelegate.getTopicFactoryComm();
    targetT = ServerDelegate.getTopicNameComm();
    connection = targetTCF.createTopicConnection();
    session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    topicSubscriber = session.createSubscriber(targetT);
    topicSubscriber.setMessageListener(this);
    connection.start();
    System.out.println("[CommJMSReceiver] Common Topic Connection successed");
    } catch (Exception ex) {
    System.out.println("[CommJMSReceiver] Common Topic Connection failed");
    ex.printStackTrace();
    </code>
    Message was edited by:
    PaulSheldonII_Screen

  • How to realize only one identical remoteApp per session per user per computer?

    If a terminalserver 2008 R1 is configured for only one session per user, everything works like it should if the user connects using the 'normal' remotedesktop session. A second connect with the same credentials kicks the first connect.
    If a remoteApp is used instead of the 'normal' connect, it's possible to start multiple instances of this app within one user a least from one computer. mstsc do run multiple times and seem to link in the existent connection without kicking it. How to change
    that?
    Continuative:
    The started RemoteApp checks the mutex of all started processes and stops herself if a process is found with the same mutex. This prevents multiple instances of this app within one user with the same sessionID. If a terminalserver is configured for only
    one session per user, this RemoteApp shouldn't start multiple within one user. Using a "normal" remote desktop session the app doesn't start more than one time, I tested it. Used as RemotApp, the app starts multiple! Possibly I'm able to change this behaviour
    with a code fix instead of configuring terminal services. Any tips regarding mutex and terminalservers?

    Hi,
    I tested the following code and it is working for me both in a RemoteApp and Full session:
    Imports System.Threading
    Module Main
    Sub Main()
    Dim createdNew As Boolean
    Dim m As New Mutex(True, "TPMutex", createdNew)
    If Not createdNew Then
    Return
    End If
    Application.Run(Form1)
    GC.KeepAlive(m)
    End Sub
    End Module
    -TP

  • What if i need more than one prepareStatements per connection

    hi all!!
    Please take some time to look into this scenario.
    On the front end: User enters/ updates his/her records and submits. An ArrayList of object goes to backend.
    On back end: i have to loop for the size of the ArrayList submitted and see if some record is to be updated or inserted.
    Now at back end i do following steps:
    I have only one Connection object named connection.
    Step 1:
    query (say query1 )to see if the record in DB exists for the primary key as extracted from the element from ArrayList. So one prepareStatment ( say prepareStatement1) for this. I write a query and execute :
    prepareStatment1= connection.prepareStatement(query1);
    Step2 :
    A query ( say query2) to update Data in DB. And i have a separtae prepareStatement for this and i execute
    prepareStatment2 = connection.prepareStatement(query2);
    Sep3
    A query (say query3 )to insert Data in DB. And i have a separtae prepareStatement for this and i execute
    prepareStatment3 = connection.prepareStatement(query3);
    Step4:
    for: size of arraylist:
    1. take out the element at ith index from the list.
    2. see if the record exists i.e execute step1 and see if resultSet.next() is true.
    3. if record exists step2 applies so execute update query
    4. if record doesnot exist then go to step3 and execute insert query
    A weird thing happened .. insert was running fine but update was not. May be i was not checking appropriately. BUT the error that occurrd was that
    [Microsoft][ODBC SQL Server Driver]Connection is busy with
    results for another hstmt.
    So i changed my path and in loop i prepareStatement and execute query to see if record exists or not and store the result in some boolean variable and then close this prepareStatement. and if the result existed again prepare a statement for update or else prepare a statement for insert and execute the respective.
    and then again close this prepareStatement and go for next iteration of loop
    so each iteration i am preparing statement and then closing it BECAUSE Connection doesnot allow more than one statement per connection at one time. Am i right.??
    what should i do.? Although i have solved problem by closing and preparing in loop but that is so inefficient. Is there some elegant way???
    please reply.
    PS: I am using ms sql server 8.0 as my DBMS. I am developing web application using Sun Creator.

    No, you can use as many PreparedStatements as you like, all from one Connection, and you can keep them open as long as you like. (I do this with no problems.) Where you will run into problems is when you are trying to use two ResultSets at the same time. That's what the error message means, it just doesn't use JDBC terminology.

  • Allow only one session per registered user

    Hi,
    we plan to implement a security module in our application that will display at login time if the user has other sessions still open and to give him the possibility to proceed and then to automatically purge all the other sessions he has, or to stop as maybe he has the other session just in another browser / another computer.
    The APEX_WORKSPACE_SESSIONS view shows very useful information in this matter, but beside the fields in it, it would be very useful to have also the last access/activity time for that session. How is best to get this? Join with the APEX_WORKSPACE_ACTIVITY_LOG view like this?
    SELECT q1.apex_session_id, q1.user_name, q1.session_created, q2.application_id, q2.first_access, q2.last_access, q2.requests
    FROM
      (SELECT * FROM APEX_WORKSPACE_SESSIONS WHERE user_name != 'nobody') q1,
      (SELECT apex_session_id, application_id, MAX(view_date) last_access, MIN(view_date) first_access, count(*) requests
          FROM APEX_WORKSPACE_ACTIVITY_LOG
          WHERE apex_user != 'nobody'
          GROUP BY apex_session_id, application_id
      ) q2
    WHERE q1.apex_session_id =q2.apex_session_id
    ORDER BY 3 DESC;And now my second question: Is it possible to purge the previous sessions, when the user accept this option? For example the sessions that remained open, when the user just closed the browser, or IE/Windows crashed :). How can this be done?(not the IE/Windows crash as that is simple :) ) Or at least to invalidate all objects in those sessions.
    Thanks in advance,
    Florin

    I have an SR opened with Oracle support and here is what they say:
    It looks like we are hitting
    Bug 7587013 - INSERTING AND DELETING WWV_FLOW_DATA CAUSES DEADLOCK, which is also related to
    Bug 6618662 - APEX APPEARS TO BE CAUSING DEADLOCK - CASE COLLECTION.
    To further clarify the issue, these DML statements from the APEX engine are used when rendering classic reports (and in the computation of the pagination set).
    There is no fix yet for the issue, however the frequency of the issue decreases dramatically in the last version (which you currently have).
    The issue should be fixed in Apex release 4.1
    It appears that the only way this deadlock can occur is if two requests for the same APEX session are made concurrently.
    This can be due to a user getting impatient and hitting their refresh button in their browser, or a user opening up a new tab in their browser and concurrently running the same page with the same report.
    Not really helpful IMHO, suggesting to wait for a version that will not be release soon :(. If any of the APEX team engineers / PM is interested I can dig deeper into the issue and isolate the whole chain of requests from an user that hits this error, which unfortunately appears more and more often lately :(. I need to find at least an workaround if not a fix as now I get daily at least 7 such ORA-60 Deadlock detected issues.
    Just last week I was able to produce a nice testcase for a bug in APEX_MAIL, and prod dev made the patch in less than a day, with all the timezone difference issues. I was pretty impressed when getting that quick the patch 9414444 (thanks Joel :) ).
    Florin

  • Enlisting a JMS session as part of a distributed tx in SFSB

    Consider the following method in a SFSB (Seam 2.1.2, JBoss 4.2 AS, EJB 3.0, JPA 1.0, Hibernate as persistence provider). I am trying to enlist the JMS session as part of the distributed tx and testing this using both local-tx-datasource and xa-datasource (JBoss specific datasources). Apparently the JMS session is not joining the distributed tx because everything is working fine using local-tx-datasource, which it should not. I'm guessing that there are two separate tx's that are happening here instead of one distributed tx. Also, note the following:
    //topicSession = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
    topicSession = conn.createTopicSession(true, TopicSession.AUTO_ACKNOWLEDGE);     The first param in the createTopicSession() method marks it as transacted, which may be used to commit all or none of multiple JMS messages in a tx (e.g. publishing multiple topics to a message queue and guaranteeing atomicity). But I was thinking that would make JTA enlist it in the distributed tx and apparently it does not.
    As per section 13.2.2 of JSR220-core:
    "Behind the scenes, the EJB server enlists the session on the connection to the JMS provider
    and the database connections as part of the transaction. When the transaction commits, the EJB
    server and the messaging and database systems perform a two-phase commit protocol to ensure atomic
    updates across all the three resources."
    Somebody please explain what/how the transactional semantics are in this case when enlisting a db resource mgr and a JMS session resource mgr in a distributed tx (with or w/o Seam).  thx.
    SFSB:
    @Name("startConversation")
    @AutoCreate
    @Install(true)
    @Stateful
    public class TestStartConversation implements TestStartConversationLocal{
    @Logger
    private Log log;
    @In
    private EntityManager em;
    @In
    private EntityManager em2;
    private transient TopicPublisher topicPublisher;  
    private transient TopicSession topicSession;
    private transient TopicConnection conn;
    private transient Topic topic;
    public void startup(){
    log.info("in startup()");
    List<Hotel> list = em.createQuery("from Hotel").getResultList();
    log.info("list.size() = "+list.size());
    Hotel hotel = null;
    if (list != null && list.size() > 0) {
    hotel = list.get(0);
    hotel.setAddress("arbi's house1");
    try{
    InitialContext iniCtx = new InitialContext();
    Object tmp = iniCtx.lookup("ConnectionFactory");
    TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
    conn = tcf.createTopicConnection();
    topic = (Topic) iniCtx.lookup("topic/chatroomTopic");
    //topicSession = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
    topicSession = conn.createTopicSession(true, TopicSession.AUTO_ACKNOWLEDGE);            
    topicPublisher = topicSession.createPublisher(topic);
    topicPublisher.publish( topicSession.createObjectMessage(new ChatroomEvent("connect", "arbime")) );
    topicSession.commit();            
    catch(Exception e){
    //noop
    finally {
    try {
    topicSession.close();
    conn.close();
    catch(Exception e) {
    //noop
    }MDB:
    @MessageDriven(activationConfig={
    @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
    @ActivationConfigProperty(propertyName="destination", propertyValue="topic/chatroomTopic")
    @Name("logger")
    public class LoggerBean implements MessageListener
    @Logger Log log;
    public void onMessage(Message msg)
    try
    ChatroomEvent event = (ChatroomEvent) ( (ObjectMessage) msg ).getObject();
    log.info( "#0: #1", event.getUser(), event.getData()==null ? event.getAction() : event.getData() );
    catch (JMSException jmse)
    throw new RuntimeException(jmse);
    }

    I am using the following code now with the same results. It works w/o enlistment exception which is not what I'm expecting. So apparently there's no distributed tx? How can I check to see if there is a distributed tx and what resources (if any) have been enlisted?
    private transient TopicPublisher topicPublisher;  
         private transient XATopicSession topicSession;
         private transient XATopicConnection conn;
         private transient Topic topic;
         /******************************* begin methods *******************************/
         @TransactionAttribute(TransactionAttributeType.REQUIRED)
         public void startup(){
              log.info("in startup()");
              List<Hotel> list = em.createQuery("from Hotel").getResultList();
              log.info("list.size() = "+list.size());
              try{
                   InitialContext iniCtx = new InitialContext();             
                   XATopicConnectionFactory tcf = (XATopicConnectionFactory) iniCtx.lookup("XAConnectionFactory");
                  conn = tcf.createXATopicConnection();
                  topic = (Topic) iniCtx.lookup("topic/chatroomTopic");
                  topicSession = conn.createXATopicSession();         
                  topicPublisher = topicSession.getTopicSession().createPublisher(topic);
                  topicPublisher.publish( topicSession.createObjectMessage(new ChatroomEvent("connect", "arbime")) );
              catch(Exception e){
                   //noop
              finally {
                   try {
                        topicSession.close();
                        conn.close();
                   catch(Exception e) {
                        //noop
         }

  • JMS Session and Container Managed Tx

              Hello,
              We have encountered the following problem:
              1) A Transaction was initiaited by the Container on EJB1.a() ("Required"-in CMT)
              2) a topic jms session was initiated by: cSession = connection.createTopicSession(
              false, TopicSession.AUTO_ACKNOWLEDGE );
              3) When I rollback the tx, all but the jms sendings roolback. Meaning the jms
              session was not a part of the tx.
              How do I relate between a jms session and a container transaction. Do I necessarily
              have to use user transaction to solve this problem?
              Many thanks in advance,
              

    Danger. Please read in-line comment.
              David Maddison wrote:
              > Hi Daniel,
              >
              > The topic session you've created isn't a transactional one, (you supplied
              > false to the transactional parameter)
              >
              > You need to use :
              >
              > cSession = connection.createTopicSession(true,
              > TopicSession.AUTO_ACKNOWLEDGE );
              >
              > To create a transactional session which will be enrolled in the CMT
              > transaction.
              >
              This is 100% wrong. Making a session transacted specifically causes JMS
              to ignore any existing transaction in favor the session's internal transaction,
              as required by the JMS specification. You need to use a connection
              that specifically checks for JTA (user) transactions. Either use an
              XAConnection
              or use a connection factory with the "user transactions enabled" flag set.
              There are number of transaction
              questions answered in the FAQ, they should point you in the right
              direction:
              http://e-docs.bea.com/wls/docs61/faq/jms.html
              The JMS programmer's guide also has this information.
              Tom, BEA
              >
              > David Maddison
              >
              > "Daniel Gordon" <[email protected]> wrote in message
              > news:[email protected]...
              > >
              > > Hello,
              > >
              > > We have encountered the following problem:
              > >
              > > 1) A Transaction was initiaited by the Container on EJB1.a()
              > ("Required"-in CMT)
              > > 2) a topic jms session was initiated by: cSession =
              > connection.createTopicSession(
              > > false, TopicSession.AUTO_ACKNOWLEDGE );
              > >
              > > 3) When I rollback the tx, all but the jms sendings roolback. Meaning the
              > jms
              > > session was not a part of the tx.
              > >
              > > How do I relate between a jms session and a container transaction. Do I
              > necessarily
              > > have to use user transaction to solve this problem?
              > >
              > > Many thanks in advance,
              > >
              > >
              

  • Non-durable subscribers persists after the end of their JMS session

    Hi all,
    I'm using OAQ as my JMS Provider.
    I have created code for publishing and recieving messages to/from topics. Messaging works fine, but I have one problem:
    All my non-durable subscribers persists after the end of their JMS session. I always perform unsubscribe operation in code and then closing session and connection.
    When I subscribe to topic, there's one more line in DB table ( etc. NAME: TSUB_1_24E6DB98A2EB7712E040A8C, TYPE: 65). I have expected that subscribers will be deleted after performing unsubscribe operation, but they don't...
    Can you help me with this problem? Thanks for any answer.
    Best Regards,
    Juraj

    Have you found a solution to this yet - because I face the same problem

  • Unable to create a transacted JMS Session

              We have some code that worked perfectly under wls7.0 and earlier, but refuses to
              work under wls8.1. In our situation, we are unable to create a JMS Session with
              internal transactions.
              The result of the following code
              System.out.println("transacted_=" + transacted_);
              tsession=tcon.createTopicSession(transacted_, Session.AUTO_ACKNOWLEDGE);
              System.out.println("session.getTransacted()=" + tsession.getTransacted());
              is the following
              transacted_=true
              session.getTransacted()=false
              We have tried using xa true and false; but commonly use false.
              //from config.xml
              <JMSConnectionFactory JNDIName="corej2ee.jms.JMSConnectionFactory"
              Name="CoreJMSConnectionFactory" Targets="myserver"/>
              thanks,
              jim
              

    An alternative is to modify the servlet code to use global (user)
              transactions instead of local (transacted session)
              transactions - the performance will likely be the same in your case -
              or may actually improve due to the activation of the pooling code.
              jim stafford wrote:
              > You were correct about us using the resource-ref. The documentation seemed to indicate
              > that our servlet code should have worked as initially developed, however the new
              > changes work
              >
              > //replace resource-ref lookup with env-entry to allow transacted JMS
              > //sessions. This is new with wls8.1
              > //tconFactory = (TopicConnectionFactory)
              > // ctx.lookup("java:comp/env/jms/topicFactory");
              > String factoryName =
              > (String)ctx.lookup("java:comp/env/jms/myConnectionFactory");
              > System.out.println("using global jndi name:" + factoryName);
              > tconFactory = (TopicConnectionFactory)
              > ctx.lookup(factoryName);
              > tcon = tconFactory.createTopicConnection();
              >
              > System.out.println("transacted_=" + transacted_);
              > tsession=tcon.createTopicSession(transacted_, Session.AUTO_ACKNOWLEDGE);
              > System.out.println("session.getTransacted()=" + tsession.getTransacted());
              >
              > --- output
              > Looking up topic connection factory
              > using global jndi name:corej2ee.jms.JMSConnectionFactory
              > transacted_=true
              > session.getTransacted()=true
              >
              > Tom Barnes <[email protected]> wrote:
              >
              >>Hi Jim,
              >>
              >>My first thought is that the app is running
              >>on the WL server and that the app is using EJB "resource
              >>references" to indirectly access its JMS resources.
              >>Stricter J2EE compliance in 8.1 causes JMS resources
              >>accessed via resource references to ignore the transacted flag.
              >>
              >>See "J2EE Compliance" under:
              >>http://edocs.bea.com/wls/docs81/jms/j2ee_components.html#1033768
              >>
              >>The work-around is to directly specify the JNDI name
              >>of the CF in the app directly instead of looking it up
              >>via a resource reference.
              >>
              >>Please let me know if this helps.
              >>
              >>Tom
              >>
              >>jim stafford wrote:
              >>
              >>
              >>>We have some code that worked perfectly under wls7.0 and earlier, but
              >>
              >>refuses to
              >>
              >>>work under wls8.1. In our situation, we are unable to create a JMS
              >>
              >>Session with
              >>
              >>>internal transactions.
              >>>
              >>>The result of the following code
              >>>
              >>>System.out.println("transacted_=" + transacted_);
              >>>tsession=tcon.createTopicSession(transacted_, Session.AUTO_ACKNOWLEDGE);
              >>>System.out.println("session.getTransacted()=" + tsession.getTransacted());
              >>>
              >>>is the following
              >>>
              >>>transacted_=true
              >>>session.getTransacted()=false
              >>>
              >>>We have tried using xa true and false; but commonly use false.
              >>>
              >>>//from config.xml
              >>><JMSConnectionFactory JNDIName="corej2ee.jms.JMSConnectionFactory"
              >>> Name="CoreJMSConnectionFactory" Targets="myserver"/>
              >>>
              >>>thanks,
              >>>jim
              >>
              >
              

Maybe you are looking for