JMS Transaction Questions

          Greetings,
          I have the following questions regarding Transactions in JMS:
          1. What constitutes a transaction in JMS? Assuming there are 2 clients, one which
          is just a Subscriber and the other just a Publisher. What will constitute a transaction
          in this scenario?
          2. While configuring, JMS Connection Factory, a parameter present is " Transaction
          Timeout ", with a defualt value of 3600 secs. At what point, does this time starts
          ticking ? Is there anyway to disable this value or the only solution is to increase
          it as required.
          

          vinay s wrote:
          > Greetings,
          >
          > I have the following questions regarding Transactions in JMS:
          > 1. What constitutes a transaction in JMS? Assuming there are 2 clients, one which
          > is just a Subscriber and the other just a Publisher. What will constitute a transaction
          > in this scenario?
          >
          A receive or send operation performed under a transaction. The operation
          becomes transactional.
          >
          > 2. While configuring, JMS Connection Factory, a parameter present is " Transaction
          > Timeout ", with a defualt value of 3600 secs. At what point, does this time starts
          > ticking ? Is there anyway to disable this value or the only solution is to increase
          > it as required.
          This applies to transacted sessions. A special kind of transactional behavior
          unique to JMS. WL JMS also supports user transactions (JTA), which
          is more unique.
          Note that 3600 seconds is a long time, standard transactions actually
          default to a limit of 30 seconds...
          To learn about this stuff, I recommend reading the WebLogic JMS Programmer's guide - there
          is a chapter on
          transactions. Check out the performance white-paper I posted to this newsgroup last
          Thursday - there is
          a section in there on transacted sessions vs. user transactions...
          

Similar Messages

  • Can we handle various other kind of transactions in JMS transaction?

    I know we can handle heterogenous transactions like JDBC Transactions, JMS transactions, etc from JTA.
    Can we similarly handle such various txns in JMS transactions also?
    SO say when I get a message, I need to send another message, and update some 2-3 DB instances. If any of latter 2 fails whole JMS txn should rollback.
    Is it possible in JMS?
    Please point me some online docs if available.
    Thanks in advance

    Yes it is. Use 2 Phase commit,(these are this X... Classes)
    Edited by: lieni on Jan 9, 2008 10:42 PM

  • Recovering Inactive JMS Transactions

    I'm running WL server 10.3.3 with "plain old" JMS transactions (no JTA), run from a WL JMS 'C' interface based client.
    Occasionally I see the following JMS error returned in place of a transaction timeout. I.e. this happens at the time a transaction should have timed out:
    'Attempt to resume an inactive transaction: BEA1-075EEE16749AF9834384:error resuming transacted session's internal transaction'
    Once this happens, the transaction appears to be "frozen". It cannot be committed or rolled back, since it keeps generating that same inactive transaction error. The messages associated with that transaction are "stuck" inside the application until they're committed using another session / transaction. So far, the messages read with the transaction that turns inactive don't reappear on the queue until the application exits; this means that the messages would reappear on the queue after exit, and presumably be processed a second time once the application starts again.
    Is there any way to recover/commit/rollback an inactive transaction without quitting the application that started it?
    Thanks for your help.

    I haven't tried that. However, that's a manual operation, which isn't practical to do on a customer site. I'm looking for a way to recover inactive transactions programatically.
    BTW, I found out that most of these inactive transactions are caused by the JTA transaction timeout value being set lower than the Connection Factory transaction timeout value. While that doesn't solve the problem completely, it does allow us to remove the most common source of inactive transactions by co-ordinating the timeout values.

  • Distributed JDBC/JMS transaction commit order

    I am using WLS 10.3.0. I have an app with container-managed EJBs which participate in distributed transactions using XA drivers for two resources, (1) a jdbc connection to Oracle database, and (2) WebLogic JMS server. In a typical EJB call, I am writing a record to the database and sending a message to a local queue which is being consumed by a MDB. My question is how can I guarantee that by the time the MDB receives the JMS message, the record will be guaranteed to have been committed in the database. It appears that occasionally the record is not yet there. Is there a way to force the jdbc commit to happen before the JMS message gets consumed? I know there is a commit_point_strength parameter that determines commit order for the database resource, but I don't see such a concept for JMS...

    "The Default Time-to-Deliver attribute for XAConnectionFactory for the Weblogic JMS connection queue, is a minimum interval from when the message is SENT, to when it is available to be processed. What is really needed is a delay from COMMIT time -- not from the sent time."
    <jay>
    Not entirely true. Delay is not from when message is “SENT, Default Time-To-Deliver is delay at within JMS subsystem before it delivers message to consumer. It means that "Send" thread will not block for this delay and "Send" side executes no different whether there is "Time-to-Deliver" configured or not.
    </jay>
    "For example, imagine a distributed transaction does a JMS send, followed by a query that takes 10 seconds, followed by a commit. If Default Time-to-Deliver is set to 5 seconds, it will be completly ignored, since the 10 seconds from the send to the commit is a larger interval. So at commit it is still very possible that the MDB will receive the message before the database transaction is committed."
    <jay>
    This is not true also. JMS message will be available for delivery only after distributed transaction commits and more specifically "commit" part of the JMS resource completes - clock for "message delivery delay" will not start until distributed transaction is committed. Considering transaction will not commit until slow running query completes execution above scenario will not cause “Default Time-to-Deliver” workaround to fail.
    Slow execution of the XA.commit() request from TM (Weblogic) to database may cause concern , however considering that TM (WebLogic) receive response of the XA.prepare() from all participating resources before XA.commit(), commit should execute with delay not more than few milliseconds and chances are negligible that proposed workaround will fail.
    </jay>
    "The bottom line, is that this parameter is not an effective way to control the race condition unless the JMS send is always performed as the last action in a distributed transaction.
    For this reason we have gone with inserting a small configurable sleep at the start of the onMessage() methods in the MDB. Not a very elegant solution, but the one ne that works reliably."
    <jay>
    I think "Default Time-to-Deliver" is no less effective or no less reliable solution than placing sleep() in onMessage(), however it is more cleaner solution because it uses application server built in feature instead of updating code in onMessage().
    </jay>
    -jayesh@yagna

  • JMS queue question

    Hi all,
    I am using Weblogic Application Server and say I have 1000 messages in a JMS Queue say "Q1".
    Q1. How are these messages picked up from the queues? i.e. by a thread etc.
    Q2. If they are picked up by threads then who configures these threads? Are they default threads created by the Weblogic Application Server or are user-created threads?
    Q3. Also, if 20 threads are involved in picking the messages from the queue and of them one thread snaps while picking the message then what will happen? and what will be the solution??
    Thanks.

    Q1/Q2*:
    The answer to your question is "its provider specific".
    You will need someone who explicitly works on weblogic to provide specifics so you may want to utilize a weblogic specific forum instead of a generic JMS forum
    I'll try to answer this in very generic terms that should apply to all providers:
    If you are receiving messages with an MDB: there is a thread pool associated with the resource adapter which plugs the JMS provider into the server. This is generally configured as part of the application server configuration. That pool dictates the maximum number of threads which can call the same MDB's at the same time.
    If you are receiving messages with a Servlet: In this case, you are probably calling receive within the servlet. That will use the thread provide by the webstack which is executing the servlet
    If you are receiving messages in an AppClient or Standalone provider: You are using your own thread if you call receive(), or a thread provided by the provider if you are calling onMessage()
    In all cases, the provider may be allocating additional threads "beneath the covers" to process those messages.
    Q3*:
    I'm not quite sure what snaps means. Threads run until they exit. I'm going to guess that the question is "what if the MDB or code throws a RuntimeException". If you mean something different, please supply a more specific description of the error.
    This one depends on what whether or not you are using transactions and how you are receiving those messages.
    If you are using transactions in an MDB: the transaction will rollback and the message will be redelivered to another consumer.
    In all other cases, it depends on the specifics (I was going to list them but it seems like to much work for a Friday afternoon).
    If you are using a non-transacted or non-MDB method to retrieve the messages, let me know and I can tell you how, per the JMS and J2EE specs, it should work. I'll need to know acknowledge mode/transaction, type of client and if you are calling receive() or onMessage().
    -- Linda

  • JMS transaction between two queues

    Hi there,
              I have been asked to build some code that will act as an adapter
              between two legacy systems. Basically I will have to read from a
              queue, transform the information and write it to the other, then
              receive the response, transform it, and put it again back to the
              "caller" system.
              There are 4 queues implicated in this task.
              I will to use JMS Api in my code but I have found a problem. The way
              of performing a transaction in JMS is this:
              QueueSession queueSession = queueConnection.createQueueSession(true,
              0);
              "Here, the first argument means that the session is transacted; the
              second indicates that message acknowledgment is not specified for
              transacted sessions."
              As queueConnection is a connection to ONE queue, I can only perform
              transactions to ONE queue! But I don´t want to consume a message till
              I know it has been sent correctly to the other side.
              I have also read that some JMS providers support JTA transactions.
              But I don´t know if this is the right way to go.
              Can anybody bring some light to this issue.
              Thaks al lot for your attention!!
              

              This post has blossomed into several threads. I'm going to
              attempt a shot-gun approach to answer all questions.
              On MQSeries:
              See "How to use IBM MQ as a JMS Provider?" posts for more info.
              On transacted sessions:
              If this is ALL MQSeries, then it is up to MQSeries if a transacted
              session can span multiple queues and/or servers. WL supports this.
              MQSeries may simply prevent a session from
              spanning multiple servers and/or queues. Note that other vendors,
              that do not have their own TX monitor, very very likely do
              not have a 2PC in a transacted session that spans multiple servers
              (meaning it is not truly transactional).
              On JTA and multiple queues:
              The whole reason for being for JTA is to be able to span multiple
              operations. Yes, this is supported in WL.
              On the manuals:
              These issues are covered in great detail in the WL JMS developer's
              guide in the transactions chapter.
              On bridging:
              You do not have to write your own bridge.
              WL supplies a bridge to greatly simplify the work involved.
              WL 7.0 can even bridge two XA compliant JMS implementations transactionally.
              (Neither has to be WL JMS.) WL 6.1SP3 will have this same feature, now
              avialable as alpha code in 6.1. See "How to use IBM MQ as a JMS Provider?" posts for more
              info.
              On queuing and transactions:
              One can not include a request and its response in the same transaction. Period.
              This is the nature of queueing. One can dequeue from one queue and
              enqueue to another. I think you understand this, but it bears repeating.
              Tom
              Mac wrote:
              > I know that a recieve will not remove a message and a send will not
              > send it until the transaction is commited.
              >
              > In fact I want to do 2 transactions one for each receive-send.
              >
              > graphic again! ;)
              >
              > queue1 queue3
              > ======> =====>
              > legacy 1 Java Adapter legacy 2
              > queue2 queue4
              > <====== <=====
              >
              > In the period of time between reading from queue1 and writing to
              > queue3 the adapter could fail thus a message will be lost. The same
              > happens with queue4 and 2. Maybe this could be solved with a
              > transaction over queue1 and another one over queue4, but I'm not sure.
              >
              > I will have to decide if I use JMS or MQSeries API. MQ allows you to
              > wrap more than one queue in the same transaction if they are in the
              > same Queue Manager. So I wanted to know if JMS also allows to make a
              > transation over more than one queue and how is it done. only JTA?
              > QueueSession? impossible?
              >
              > tnx really for your help!
              >
              > "Raja Mukherjee" <[email protected]> wrote in message news:<[email protected]>...
              > > You can not. Even if you could, it's at least have to be 2 transactions.
              > > Because, if all of your work is in one transaction you will never send or
              > > receive messages, you would be blocking for ever. In order to send the
              > > message you will have to commit the transaction on the first place.
              > >
              > > .raja
              > >
              > > "Mac" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > Sorry Tom, I think that I have not explained well my problem.
              > > >
              > > > The following extrange symbols are supposed to be an explaining
              > > > graphic!! ;)
              > > >
              > > >
              > > > queue1 queue3
              > > > ======> =====>
              > > > legacy 1 Java Adapter legacy 2
              > > > queue2 queue4
              > > > <====== <=====
              > > >
              > > > Legacy System 1 wants to call a service of legacy system 2, but they
              > > > can not communicate directly so we will use MQ Series as both them
              > > > support it.
              > > > For that purpose Legacy1 puts a message in queue1. The Java Adapter
              > > > transforms the message and puts it in queue3. Legacy2 processes the
              > > > request and replies with a message in queue4. The Java Adapter gets
              > > > it, transforms it and puts it in queue2. As a result legacy1 obtains
              > > > the information it was asking for.
              > > >
              > > > I'm using MQ Series 5.2 as middleware. I will not use Message Driven
              > > > Beans so I won´t have an EJB container to perform distributed
              > > > transactions.
              > > >
              > > > The question is: How can I put and get messages in the 4 queues
              > > > using de same transaction?? Can I do it somehow with JMS session or I
              > > > must use a JTA transaction?
              > > >
              > > > Thanks again for your help, and forgive me for being so insistent!
              > > > :)
              [att1.html]
              

  • JMS (Transaction ???) problem, consumer receives all messages at once.

    Hallo, I have an application which implements asynch communication between the web and business layer using JMS.
    On a page a user can upload files, which are processed by the backend. For large files this can be a long running process, thats why we use JMS to send the file asynchronously and use JMS to update progress information on the page.
    The application works fine on JBoss 6 with HornetMQ.
    After porting to Weblogic I see consistently a strange phenomenon. The update messages from the processing backend logic are send as expected. But the receiver does not receive one message after another but receives all the messsages almost at once after only the producer has sent the last message.
    For me this is totally unexpected behavior and of course our progress bar on the page does not work properly, but merely jumps from 0 to 100% after the data has been processed.
    It looks like the consumer waits until the producer has finished its transaction. But how can this be possibly? I have learned that transaction never span producer - messagesystem - consumer.
    Example Code:
    Producer:
    import javax.annotation.PostConstruct;
    import javax.annotation.PreDestroy;
    import javax.annotation.Resource;
    import javax.ejb.EJB;
    import javax.ejb.Stateless;
    import javax.interceptor.Interceptors;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.DeliveryMode;
    import javax.jms.Destination;
    import javax.jms.JMSException;
    import javax.jms.MessageProducer;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import org.apache.log4j.Logger;
    import com.sun.tools.ws.wsdl.document.jaxws.Exception;
    import dsde.core.aspects.DsdeException;
    import dsde.core.aspects.ExceptionHandler;
    import dsde.core.entity.Data;
    @Stateless
    @Interceptors(ExceptionHandler.class)
    public class ParserBean implements Parser {
         private Logger log = Logger.getLogger(this.getClass());
         @EJB
         private DataDAO dataDAO;
         //Weblogic
         @Resource(mappedName="jms.BackQueue")
         //Jboss
         //@Resource(mappedName="queue/dsdeBackQueue")
         private Destination backQueue;
         //Weblogic
         @Resource(mappedName="jms.dsdeConnectionFactory")
         //JBoss
         //@Resource(mappedName="XAConnectionFactory")
         private ConnectionFactory connectionFactory;
         private Connection connection;
         @Override
         public void parse(String text, String description, String sessionId) throws DsdeException{
              double percentDone = 0;
              double j = 0.0;
              //Simuliere was langdauerndes, schwieriges
              for (int i=0; i < text.length(); i++) {
                   j = i;
                   percentDone = j / text.length() * 100;
                   try {
                        Thread.sleep(1000);
                   } catch (InterruptedException e) {
                        log.error(e);
                   if (i % 2 == 0) {
                        //periodisch das Frontend mit dem Fortschritt updaten
                        sendFeedback((int)percentDone, sessionId);
              //Zum Schluss noch senden dass wir fertig sind
              //Sonst wird der Send Button nicht wieder aktiv
              percentDone=100;
              sendFeedback((int)percentDone, sessionId);
              //Jetzt wird noch richtig geparsed :-)
              String[] words = text.split(" ");
              //Entity konstruieren
              Data data = new Data(description, words);
              //Das Ergebnis in die Datenbank schreiben
              dataDAO.saveData(data);
         private void sendFeedback(int percentDone, String sessionId) {
              Session session = null;
              try {
                   session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                   MessageProducer producer = session.createProducer(backQueue);
                   producer.setTimeToLive(50000);
                   producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
                   TextMessage message = session.createTextMessage();
                   message.setJMSCorrelationID(sessionId);
                   message.setText("" + percentDone);
                   producer.send(message);
                   log.info("ParserBean has sent " + percentDone);
              } catch (JMSException e) {
                   log.error(e);
              } finally {
                   if (session != null) {
                        try {
                             session.close();
                        } catch (JMSException e) {
                             log.error(e);
         @PostConstruct
         public void init(){
              try {
                   connection = connectionFactory.createConnection();
              } catch (JMSException e) {
                   log.error(e);
         @PreDestroy
         public void close() {
              try {
                   connection.close();
              } catch (JMSException e) {
                   log.error(e);
    }Consumer:
    import javax.annotation.ManagedBean;
    import javax.annotation.PostConstruct;
    import javax.annotation.PreDestroy;
    import javax.faces.bean.SessionScoped;
    import javax.faces.context.FacesContext;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageListener;
    import javax.jms.Queue;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.servlet.http.HttpSession;
    import org.apache.log4j.Logger;
    @ManagedBean
    @SessionScoped
    public class FeedbackReceiverBean implements MessageListener {
         private Logger log = Logger.getLogger(this.getClass());
         //jndi names of managed objects
         private String connectionFactoryName;
         private String queueName;
         private Connection connection;
         private Session session;
         private int percent;
         private boolean disabled;
         public boolean isDisabled() {
              return disabled;
         public void setDisabled(boolean disabled) {
              this.disabled = disabled;
         public int getPercent() {
              return percent;
         public void setPercent(int percent) {
              this.percent = percent;
         public void setConnectionFactoryName(String connectionFactoryName) {
              this.connectionFactoryName = connectionFactoryName;
         public void setQueueName(String queueName) {
              this.queueName = queueName;
         @PostConstruct
         public void init() throws NamingException, JMSException {
              FacesContext facesContext = FacesContext.getCurrentInstance();
              HttpSession httpSession = (HttpSession) facesContext.getExternalContext().getSession(false);
              String sessionId = httpSession.getId();
              Context context = new InitialContext();
              ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup(this.connectionFactoryName);
              Queue queue = (Queue) context.lookup(this.queueName);
              this.connection = connectionFactory.createConnection();
              this.session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              String filter = "JMSCorrelationID = '" + sessionId + "'";
              MessageConsumer consumer = session.createConsumer(queue, filter);
              consumer.setMessageListener(this);
              connection.start();
         @PreDestroy
         public void close() throws JMSException {
              this.session.close();
              this.connection.close();
         @Override
         public void onMessage(Message message) {
              if (message instanceof TextMessage) {
                   TextMessage textMessage = (TextMessage) message;
                   try {
                        this.percent = Integer.parseInt(textMessage.getText());
                        if (percent >= 100) {
                             this.disabled = false;
                        log.info("Prozent " + percent);
                   } catch (JMSException e) {
                        log.error(e);
              else {
                   log.error(message.toString() + " is no TextMessage");
         public void disable() {
              this.disabled = true;
    }Configuration:
    <?xml version='1.0' encoding='UTF-8'?>
    <weblogic-jms xmlns="http://xmlns.oracle.com/weblogic/weblogic-jms" xmlns:sec="http://xmlns.oracle.com/weblogic/security" xmlns:wls="http://xmlns.oracle.com/weblogic/security/wls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-jms http://xmlns.oracle.com/weblogic/weblogic-jms/1.1/weblogic-jms.xsd">
      <connection-factory name="dsdeConnectionFcatory">
        <default-targeting-enabled>true</default-targeting-enabled>
        <jndi-name>jms/dsdeConnectionFactory</jndi-name>
        <default-delivery-params>
          <default-delivery-mode>Persistent</default-delivery-mode>
          <default-time-to-deliver>0</default-time-to-deliver>
          <default-time-to-live>100</default-time-to-live>
          <default-priority>4</default-priority>
          <default-redelivery-delay>0</default-redelivery-delay>
          <send-timeout>10</send-timeout>
          <default-compression-threshold>2147483647</default-compression-threshold>
        </default-delivery-params>
        <client-params>
          <client-id-policy>Restricted</client-id-policy>
          <subscription-sharing-policy>Exclusive</subscription-sharing-policy>
          <messages-maximum>10</messages-maximum>
        </client-params>
        <transaction-params>
          <xa-connection-factory-enabled>true</xa-connection-factory-enabled>
        </transaction-params>
        <security-params>
          <attach-jmsx-user-id>false</attach-jmsx-user-id>
        </security-params>
      </connection-factory>
      <queue name="dsdeQueue">
        <sub-deployment-name>dsdeQueue</sub-deployment-name>
        <jndi-name>jms/dsdeQueue</jndi-name>
      </queue>
      <queue name="dsdeFeedbackQueue">
        <sub-deployment-name>dsdeFeedbackQueue</sub-deployment-name>
        <jndi-name>jms/dsdeFeedbackQueue</jndi-name>
      </queue>
      <queue name="dsdeBackQueue">
        <sub-deployment-name>dsdeBackQueue</sub-deployment-name>
        <jndi-name>jms/BackQueue</jndi-name>
      </queue>
    </weblogic-jms>Any help would be greatly appreciated.
    Thanks,
    Hans

    Thanks for posting your analysis!
    I think your solution is probably best.
    FYI: Your JMS session was never a "transacted" session. It's definitely confusing, but the term "transacted session" has a special meaning in JMS, it actually refers to a session that is not XA/JTA aware and instead maintains an internal local transaction that's scoped only to the current JMS session's operations. A transacted session is created by passing "true" to the first parameter of createSession, and such a session's local transaction is committed by calling session.commit() (which starts a new transaction). To further add to the confusion, I think that JEE servers are actually obligated to ignore requests to set the transacted flag to true -- WebLogic does this trick by secretly wrapping access to the JMS API when applications lookup JMS connection factories via a resource reference.
    Regards,
    Tom

  • JMS transaction rollback from Javacallout

    Hi,
    I have a proxy which insert message into queue via business service, and i have another proxy which pull message from queue and call to javacallout which returns boolean (true/false). During some processing javacallout return a boolean false. I have managed for checking if the boolean returned in false then i want to rollback the transaction and message to put back to queue.
    I have setting "Is XA required = true" and JMS proxy configured for XA connection.
    When i recieve boolean false from javacallout i am raising error which is not handled by any error handler. I dont have stage error handler, no service error handler and hence according to me error should propegate and it should rollback.
    But message is not rollback to queue.
    I have "Redelivery Delay Override", "Redlivery Limit" property set to -1 (default) and "Expiration Policy" set to "Discard" and no "Error Destination" selected for Queue setup.
    I am using Oracle Service Bus 10gR3 version.
    I am new to this type of configuration and i suppose i am missing some configuration here.
    Please help me, its little urgent.
    Thanks
    Sujit

    Hi Sujit,
    I have "Redelivery Delay Override", "Redlivery Limit" property set to -1 (default) and "Expiration Policy" set to "Discard" and no "Error Destination" selected for Queue setup.
    Change the Redelivery Limit field  to 3 ( specify the number of redelivery tries a message can have before it is moved to an error destination  like three times)
    Select Redirect as Expiration Policy.
    Select ErrorQueue ( Queue where you wants the rollback message should enqueue) as the Error Destination value.
    make sure to use XA connection factory.
    Hope it helps ..
    Regards,
    Abhinav Gupta

  • More Transaction Questions

    I posted this under an answered question but realized I should have started a new thread.
    Some more questions on transactions:
    XmlTransaction txn = DBManager->Manager->createTransaction();
    res = DBManager->Manager->query(txn, query.str(), queryContext, 0);
    XmlValue on;
    while( res.next(on) )
    c->Response += on.asString();
    txn.commit();
    In the above code does the txn.commit() have to happen after the processing of the result? In other words what happens if the transaction is committed before the while loop?
    Second question, in another section of the code I am doing similar to the above the difference is the query result is a list of documents to be deleted so the while loop is more like this:
    while( res.next(on) )
    container->deleteDocument(txn, on.asString(), context);
    If I am deleting several thousand documents (in this case 2300) will there be an issue with the transaction being able to hold that many deletes?

    Hello,
    2 good questions.
    1. It depends. If you have returned constructed content (e.g. return <foo>{...}</foo>) where the values will not refer to the container nodes then you can safely commit right after the query unless you are using lazy evaluation, in which case you cannot commit until you are done iterating. If any results may point into the container you cannot commit until you've processed them all or can otherwise guarantee that you won't touch the container outside the transactions.
    If you violate the rule you'll get an exception saying so.
    2. 2300 results isn't that large. The issues related to deleting so much content in a single transaction include:
    a. a lot of data written to the log at commit time
    b. using a fair bit of resource in terms of locks, etc
    c. concurrency -- holding off other operations. document deletion is at least as time-consuming as insertion
    If any of these are real problems for you, you could copy the document names somewhere and delete them in bite-size chunks in separate transactions.
    Regards,
    George

  • JMS Transaction problem

    Hi
    I am using JBoss 3.2.3 and I have a MDB which calls up some entity beans Home and Business methods.
    onMessage use both JMS and JDBC transactions and I have configured my Oracle-XA-Ds to handle transactions.
    10:22:32,415 WARN [TransactionImpl] XAException: tx=TransactionImpl:XidImpl [Fo
    rmatId=257, GlobalId=sanjeewad//33, BranchQual=] errorCode=XAER_RMERR
    oracle.jdbc.xa.OracleXAException
    at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1157
    at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:29
    5)

    Are you using Container Managed Transactions or Bean Manager Transactions? If CMT, what is the type set to 'Required'? You need Required in a CMT MDB to enable an XA transaction to be created /joined/rolled back.
    Scott
    http://www.swiftradius.com

  • Just another cmp transaction question

    Hi
    I would like to know if it is possible to manage cmp transaction from the client code. For example I need to
    execute some business method several times but I don't want the container to commit transaction after each execute but only if all executes were successfull.
    Bartek

    I think I understand your post but my problem is rather different. I have a session bean with a business method named process(..) that receives as an argument a org.dom4j.Document object and does an proper action. I works fine when that process() method is called only one . But now I wan't to call it several times , each time with different org.dom4j.Document perhaps and want to have tha transaction commited only after complete whole process. I am quite new I ejbs so it is possible that is quite a silly question but I need surety that the only way to do this is to make an another session bean business method that gets as a parameter for example a collection of org.dom4j.Document objects.
    Thanks for help
    Bartek

  • OSB JMS transaction

    I'm trying to setup a proxy service to dequeue a message from JMS and submit to a business service. If the business service fails, I want the jsm message to remain in the queue/"rollback". I setup a queue CF with "XA Connection Factory Enabled", and I have a proxy service dequeueing from a queue through that connection factory. In the proxy service I have the "Is XA Reuired" box checked on the "JMS Transport" tab, and in the message flow, I have a route node with an exception handler that is calling the business service that I have setup to fail on purpose. The exception handler has a Reply "with failure" action.
    OSB-PS -> JMS -> OSB-PS -> OSB-BS -> Failing Service
    I want this to roll back to the JMS queue.
    Did I miss anything in setting up the XA support for this process? When I invoke the proxy service, it errors off, but the message doesn't get rolled back to the original queue.
    Does anyone have an example or docs on how to set this up?
    Thanks for any help.

    Hi All,
    I have checked the Retry with Application Errors, but no change.
    Also have a Routing Option set to "Exaclty Once".
    There is also a Route error handler where I raise an error and Reply with Failure.
    The JMS Connection Factory used is XA enabled and so is the JMS Proxy service.
    The strange thing I observe is when the endpoint server is down, teh transaction gets rolled back and remains in the queue.
    However, when the server is up but the path of the URI given is either incorrect(404 HTTP Response) or there is an internal server error(500 HTTP response),
    the message is picked up from the queue and is lost.
    What I am supposing the reason would be, the proxy is able to make connection to the http uri but there is an error from the business service, while in the first case, the server is not up and hence the connection itself is failing and the transaction is getting rolled back at the request pipeline level itself.
    I compared the logs when server is down and when the path is not found-> the difference I found was
    1. Server is down: Fault occurs in the flow of the Request flow of the Route node
    2. Server is up but path not found or internal error: Fault is thrown in the response action after getting the HTTP response.
    I have even tried Raise Error and Reply with failure at the Service Error Handler level as well, but the message is lost :(
    Could anyone please help me out on this? Is there any workaround for the same?

  • JMS Transactions

    Does WLS 6.1/7.0 support JMS>JTA distributed transactions?
              http://e-docs.bea.com/wls/docs61/jms/intro.html#1048981
              http://e-docs.bea.com/wls/docs70/jms/intro.html#1048981
              Regards,
              Pieter Van Gorp.
              

    Attached...you should have the examples directory if you have installed
              samples...one of the installation option I believe...
              .raja
              "Bob Lee" <[email protected]> wrote in message
              news:[email protected]...
              > I have WebLogic Server 6.1, but I don't seem to have that example. I don't
              > have a "jms" directory at all. Can you post the relevant snippet?
              >
              > Thanks,
              > Bob
              >
              >
              > "Raja Mukherjee" <[email protected]> wrote in message
              > news:[email protected]...
              > > Yes. Take a look in the
              > > $WL_HOME/samples/examples/jms/queue/QueueReceiveInTx.java for an example
              > for
              > > receive part. Basically the same for send.
              > >
              > > .raja
              > >
              > > "Bob Lee" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > Can I use the JTS with JMS from a remote client (i.e. outside of the
              > > > application server)?
              > > >
              > > > I have a standalone client that is sending a message to the JMS server
              > in
              > > > WebLogic. I want the message to be sent in a transaction. Is this how
              it
              > > > goes?:
              > > >
              > > > Get UserTransaction via JNDI
              > > > Start Tx
              > > > Send Message
              > > > Commit Tx
              > > >
              > > > Thanks,
              > > > Bob
              > > >
              > > > "Raja Mukherjee" <[email protected]> wrote in message
              > > > news:[email protected]...
              > > > > Yes
              > > > >
              > > > > .raja
              > > > >
              > > > > "Pieter Van Gorp" <[email protected]> wrote in message
              > > > > news:[email protected]...
              > > > > > Does WLS 6.1/7.0 support JMS>JTA distributed transactions?
              > > > > >
              > > > > > http://e-docs.bea.com/wls/docs61/jms/intro.html#1048981
              > > > > > http://e-docs.bea.com/wls/docs70/jms/intro.html#1048981
              > > > > >
              > > > > > Regards,
              > > > > > Pieter Van Gorp.
              > > > > >
              > > > > >
              > > > >
              > > > >
              > > >
              > > >
              > >
              > >
              >
              >
              [QueueReceiveInTx.java]
              

  • JMS - Use question

    Hey Folks,
    Just reading a book on JMS for the first time and i just have a few philosophical questions on the use of it. In the book it gives me an example of setting up a JMS queue and then using a MDB to receive a message and then does a credit check on a customer!!
    So after one has gone through all the hassle of configuring your factories,setting up your queue, creating your MDB and then configuring it your are finally ready to write code to do your business requirements!!
    Now my first thought were, why would i do all that work just to do a credit check on a customer asynchronously, if i was using plain old POJO�s , why wouldnt i just spin off a thread to do this for me in the backround instead of having to do all the above?? So what am i missing here??
    Next point that i need some clarity on is more related to a production setup. Say i have 10 nodes, does one just create one JMS channel that all 10 nodes use or do they each have a channel for every node?? If they have a channel for every node then why would i use JMS?? Ok loose coupling, great but i can get that if i create my own observer pattern, what extra will it give me than a normal observer pattern?? I assume in the above scenario that you have no external applications listening, so everything that needs to listen for the message is in your JVM!! I understand if you have SAP or any other external applications listening
    Last but not least, is it fair to make a comparison JMS to tibco messaging bus?? If so why, if not why?? ;)
    Thanks for any help on the matter, like i said im just reading up on it now and need a few thoughts cleared up!!
    Cheers,
    LL

    > So when you say chained, i take it you can set the
    order in which you want your beans to be called
    first(assuming in a topic scenario where you have
    several listeners)?? is that possible with JMS?? if
    so how??
    We've written a custom Process Manager that receives messages and uses XPath and XSL to coordinate several JMS applications (all of our messages are XML). We typically don't use topics because we don't want multiple applications getting the same message. Each application does its work in turn, not at the same time.
    > Yeh i can see how it would work in this scenario but
    you still have other options to solve this problem
    without the need of JMS!!
    There's always more than one way to solve a problem.
    > i suppose im looking for a scenario where i would say
    to myself, yes thats a job for JMS!! And in this
    scenario exclude the need to talk to external
    applications!!
    I wouldn't want to design a large system with multiple teams working on multiple applications, each with its own processing needs without JMS. Tuning is pretty easy. Adding more horsepower at any point in the chain is pretty easy.
    But it may be that I just reach for the tools that I am most familiar with.
    Dwayne

  • Transaction questions

    Howdy all.
    I have some questions about transactions. I have a particular function that does some dynamic stuff. It creates a table dynamically, creates some indexes on the table dynamically, and grants rights to the table dynamically. I am building a string for each of these actions dynamically and executing it. Then the procedure does some other things like inserting in some tables and such. If any part of the function does not finish successfully, I would like to rollback whatever has been done. I would also like to return the initial error with original line number to the caller of the function.
    I have tried some SET TRANSACTION READ WRITE stuff with COMMIT WORK at the end of successful completion and ROLLBACK WORK in an exception handler at the end of the function. But I am having problems getting Oracle to rollback all work and return the original error to the caller.
    Here is the basic layout of what I want.
    BEGIN
    <execute immediate to create table>
    <execute immediate to create indexes on table>
    <execute immediate to grant rights to table>
    <do inserts and other non-dynamic stuff>
    EXCEPTION
    WHEN OTHERS THEN
    ROLLBACK WORK;
    RAISE <original error with line numbers>;
    RETURN (1);
    END;
    If an error happens after the creation of the table, I want the create table to be rolled back. I realize that I could just manually drop table in my exception handler, but I have several cases like this that I would like to handle with transactions instead of large exception handlers.
    Any help would be appreciated. I can explain more if needed.
    wally

    DDL issues COMMIT before and after the statement. Consequently, it cannot be rolled back. If you want to drop the tables you'll have to explicitly call the DROP statement.
    I'm not a big fan of functions to do this sort of thing, because table creation, etc ought not to be done on the fly. It should be done in a controlled fashion, in a script. Apart from anything else, a script gives you:
    (1) a record of what exactly was run, in case you need to run it again.
    (2) something that can be stowed in source control repository.
    There's no reason why the production of that script cannot be automated.
    Cheers, APC

Maybe you are looking for