Package org.objectweb.joram.shared.client

Examples of org.objectweb.joram.shared.client.ProducerMessages


    try {
      CommitRequest commitReq = new CommitRequest();

      Enumeration producerMessages = sendings.elements();
      while (producerMessages.hasMoreElements()) {
        ProducerMessages pM = (ProducerMessages) producerMessages.nextElement();
        commitReq.addProducerMessages(pM);
      }
      sendings.clear();
     
      // Acknowledging the received messages:
View Full Code Here


   
    // If the transaction was scheduled, cancelling:
    if (scheduled)
      closingTask.cancel();

    ProducerMessages pM = (ProducerMessages) sendings.get(dest.getName());
    if (pM == null) {
      pM = new ProducerMessages(dest.getName());
      sendings.put(dest.getName(), pM);
    }
    pM.addMessage(msg);

    // If the transaction was scheduled, re-scheduling it:
    if (scheduled)
      closingTask.start();
  }
View Full Code Here

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "Buffering the message.");
      // If the session is transacted, keeping the request for later delivery:
      prepareSend(dest, (org.objectweb.joram.shared.messages.Message) joramMsg.momMsg.clone());
    } else {
      ProducerMessages pM = new ProducerMessages(dest.getName(),
          (org.objectweb.joram.shared.messages.Message) joramMsg.momMsg.clone());

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "Sending " + joramMsg);

      if (asyncSend || (!joramMsg.momMsg.persistent)) {
        // Asynchronous sending
        pM.setAsyncSend(true);
        mtpx.sendRequest(pM);
      } else {
        requestor.request(pM);
      }
    }
View Full Code Here

  /**
   * Adds new sendings performed by the resumed transaction.
   */
  void addSendings(Hashtable newSendings) {
    String newDest;
    ProducerMessages newPM;
    ProducerMessages storedPM;
    Vector msgs;

    // Browsing the destinations for which messages have been produced:
    Enumeration newDests = newSendings.keys();
    while (newDests.hasMoreElements()) {
      newDest = (String) newDests.nextElement();
      newPM = (ProducerMessages) newSendings.remove(newDest);
      storedPM = (ProducerMessages) sendings.get(newDest);
      // If messages haven't already been produced for this destination,
      // storing the new ProducerMessages object:
      if (storedPM == null)
        sendings.put(newDest, newPM);
      // Else, adding the newly produced messages to the existing
      // ProducerMessages:
      else {
        msgs = newPM.getMessages();
        for (int i = 0; i < msgs.size(); i++)
          storedPM.addMessage((org.objectweb.joram.shared.messages.Message) msgs.get(i));
      }
    }
  }
View Full Code Here

      }
      ConnectionContext ctx = (ConnectionContext) connections.get(key);
      if (ctx != null) {
        AbstractJmsRequest request = ctx.getRequest(req.getMessage());
        if (request instanceof ProducerMessages) {
          ProducerMessages pm = (ProducerMessages) request;
          rm.put(req.getConnectionKey(), pm);
        } else if (request instanceof JmsRequestGroup) {
          JmsRequestGroup jrg = (JmsRequestGroup) request;
          AbstractJmsRequest[] groupedRequests = jrg.getRequests();
          for (int j = 0; j < groupedRequests.length; j++) {
            if (groupedRequests[i] instanceof ProducerMessages) {
              ProducerMessages pm = (ProducerMessages) groupedRequests[i];
              rm.put(req.getConnectionKey(), pm);
            } else {
              reactToClientRequest(key.intValue(), groupedRequests[i]);
            }
          }
View Full Code Here

    AgentId destId = AgentId.fromString(req.getTarget());
    if (destId == null)
      throw new RequestException("Request to an undefined destination (null).");

    ProducerMessages pm = req;
    if (interceptorsIN != null && !interceptorsIN.isEmpty()) {
      org.objectweb.joram.shared.messages.Message m = null;
      Vector msgs = ((ProducerMessages) req).getMessages();
      Vector newMsgs = new Vector();
      for (int i = 0; i < msgs.size(); i++) {
        m = (org.objectweb.joram.shared.messages.Message) msgs.elementAt(i);
        Iterator it = interceptorsIN.iterator();
        while (it.hasNext()) {
          MessageInterceptor interceptor = (MessageInterceptor) it.next();
          if (!interceptor.handle(m)) {
            m = null;
            break;
          }
        }
        if (m != null) {
          newMsgs.add(m);
        } else {
          // send the originals messages to the user DMQ.
          sendToDMQ((org.objectweb.joram.shared.messages.Message) msgs.elementAt(i), MessageErrorConstants.INTERCEPTORS);
        }
      }
      // no message to send. Send reply to the producer.
      if (newMsgs.size() == 0 && !msgs.isEmpty()) {
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, "UserAgent.reactToClientRequest : no message to send.");
        if (destId.getTo() == getId().getTo() && !pm.getAsyncSend()) {
          // send producer reply
          sendNot(getId(), new SendReplyNot(key, pm.getRequestId()));
        }
        return;
      }
      //update producer message.
      ((ProducerMessages) pm).setMessages(newMsgs);
      pm = req;
    }

    ClientMessages not = new ClientMessages(key, pm.getRequestId(), pm.getMessages());
    setDmq(not);

    if (destId.getTo() == getId().getTo()) {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, " -> local sending");
      not.setPersistent(false);
      not.setExpiration(0L);
      if (pm.getAsyncSend()) {
        not.setAsyncSend(true);
      }
    } else {
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, " -> remote sending");
      if (!pm.getAsyncSend()) {
        sendNot(getId(), new SendReplyNot(key, pm.getRequestId()));
      }
    }

    sendNot(destId, not);
  }
View Full Code Here

  private void reactToClientRequest(int key, JmsRequestGroup request) {
    AbstractJmsRequest[] requests = request.getRequests();
    RequestBuffer rm = new RequestBuffer(this);
    for (int i = 0; i < requests.length; i++) {
      if (requests[i] instanceof ProducerMessages) {
        ProducerMessages pm =(ProducerMessages) requests[i];
        rm.put(key, pm);
      } else {
        reactToClientRequest(key, requests[i]);
      }
    }
View Full Code Here

      throw new StateException("Unknown transaction identifier.");

    Vector sendings = prepare.getSendings();
    Vector acks = prepare.getAcks();

    ProducerMessages pM;
    ClientMessages not;
    while (!sendings.isEmpty()) {
      pM = (ProducerMessages) sendings.remove(0);
      not = new ClientMessages(activeCtxId, pM.getRequestId(), pM.getMessages());
      sendNot(AgentId.fromString(pM.getTarget()), not);
    }

    while (!acks.isEmpty())
      doReact((SessAckRequest) acks.remove(0));
View Full Code Here

    int asyncReplyCount = 0;
   
    Enumeration pms = req.getProducerMessages();
    if (pms != null) {
      while (pms.hasMoreElements()) {
        ProducerMessages pm = (ProducerMessages) pms.nextElement();
        AgentId destId = AgentId.fromString(pm.getTarget());
        ClientMessages not = new ClientMessages(key,
            req.getRequestId(), pm.getMessages());
        setDmq(not);   
        if (destId.getTo() == getId().getTo()) {
          // local sending
          not.setPersistent(false);
          if (req.getAsyncSend()) {
View Full Code Here

TOP

Related Classes of org.objectweb.joram.shared.client.ProducerMessages

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.