當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectMessage.setObject方法代碼示例

本文整理匯總了Java中javax.jms.ObjectMessage.setObject方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMessage.setObject方法的具體用法?Java ObjectMessage.setObject怎麽用?Java ObjectMessage.setObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.ObjectMessage的用法示例。


在下文中一共展示了ObjectMessage.setObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendObjectMsgSingleSession

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
private void sendObjectMsgSingleSession(List<? extends Serializable> objectsToSend) throws JMSException {
    Session session = null;
    Connection conn = null;
    try {
        conn = qFactory.createConnection();
        session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(queue);
        for (Serializable objectToSend : objectsToSend) {
            ObjectMessage msg = session.createObjectMessage();
            msg.setObject(objectToSend);
            producer.send(msg);
        }
    } finally {
        closeSession(session);
        closeConnection(conn);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:18,代碼來源:TriggerQueueServiceBean.java

示例2: send

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
/**
 * Sends a message to the myWMS application inside the application
 * server.
 * 
 * @param mfcMessage the message to be send
 * @throws JMSException
 * @throws NamingException
 */
public void send(MFCMessage mfcMessage)
    throws JMSException,
        NamingException
{

    // create the jms session
    QueueSession session =
        connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

    // lookup of the jms queue over jndi
    Queue outputQueue =
        (Queue) context.lookup("queue/" + OUTPUT_QUEUE_NAME);

    // create the message publisher
    QueueSender sender = session.createSender(outputQueue);

    ObjectMessage objectMessage = session.createObjectMessage();
    objectMessage.setObject(mfcMessage);
    objectMessage.setJMSTimestamp(System.currentTimeMillis());

    sender.send(objectMessage);
    sender.close();

    session.close();
}
 
開發者ID:salimvanak,項目名稱:myWMS,代碼行數:34,代碼來源:ServerConnection.java

示例3: append

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
/**
    This method called by {@link AppenderSkeleton#doAppend} method to
    do most of the real appending work.  */
 public void append(LoggingEvent event) {
   if(!checkEntryConditions()) {
     return;
   }

   try {
     ObjectMessage msg = topicSession.createObjectMessage();
     if(locationInfo) {
event.getLocationInformation();
     }
     msg.setObject(event);
     topicPublisher.publish(msg);
   } catch(Exception e) {
     errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e,
		 ErrorCode.GENERIC_FAILURE);
   }
 }
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:21,代碼來源:JMSAppender.java

示例4: append

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
/**
 * This method called by {@link AppenderSkeleton#doAppend} method to do most of the real appending work.
 */
public void append(final LoggingEvent event) {
   if (!checkEntryConditions()) {
      return;
   }

   try {
      final ObjectMessage msg = topicSession.createObjectMessage();
      if (locationInfo) {
         event.getLocationInformation();
      }
      msg.setObject(event);
      topicPublisher.publish(msg);
   } catch (final Exception e) {
      errorHandler.error("Could not publish message in JMSAppender [" + name + "].", e,
              ErrorCode.GENERIC_FAILURE);
   }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:21,代碼來源:JMSAppender.java

示例5: append

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
/**
 * This method called by {@link AppenderBase#doAppend} method to do most
 * of the real appending work.
 */
public void append(ILoggingEvent event) {
  if (!isStarted()) {
    return;
  }

  try {
    ObjectMessage msg = queueSession.createObjectMessage();
    Serializable so = pst.transform(event);
    msg.setObject(so);
    queueSender.send(msg);
    successiveFailureCount = 0;
  } catch (Exception e) {
    successiveFailureCount++;
    if (successiveFailureCount > SUCCESSIVE_FAILURE_LIMIT) {
      stop();
    }
    addError("Could not send message in JMSQueueAppender [" + name + "].", e);

  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:25,代碼來源:JMSQueueAppender.java

示例6: publish

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public static void publish(String dest, Serializable object, String contentType, String tag) throws Exception {
   Connection conn = connectionFactory.createConnection();
   try {
      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Destination destination = createDestination(dest);
      MessageProducer producer = session.createProducer(destination);
      ObjectMessage message = session.createObjectMessage();

      if (contentType != null) {
         message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, contentType);
      }
      if (tag != null) {
         message.setStringProperty("MyTag", tag);
      }
      message.setObject(object);

      producer.send(message);
   } finally {
      conn.close();
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:22,代碼來源:SelectorTest.java

示例7: jmsSendMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
private void jmsSendMessage(Serializable value, String destName, boolean isQueue) throws JMSException {
   ConnectionFactory factory = new ActiveMQJMSConnectionFactory("tcp://localhost:61616");
   String jmsDest;
   if (isQueue) {
      jmsDest = QUEUE_QUALIFIED_PREFIX + destName;
   } else {
      jmsDest = TOPIC_QUALIFIED_PREFIX + destName;
   }
   Destination destination = ActiveMQDestination.fromPrefixedName(jmsDest);

   Connection conn = factory.createConnection();
   try {
      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer producer = session.createProducer(destination);
      ObjectMessage message = session.createObjectMessage();
      message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, "application/xml");
      message.setObject(value);
      producer.send(message);
   } finally {
      conn.close();
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:23,代碼來源:RestDeserializationTest.java

示例8: send

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
@Override
public JMSProducer send(Destination destination, Serializable body) {
    try {
        ObjectMessage message = session.createObjectMessage();
        message.setObject(body);
        doSend(destination, message);
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }

    return this;
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:13,代碼來源:JmsPoolJMSProducer.java

示例9: send

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
@Override
public JMSProducer send(Destination destination, Serializable body) {
    try {
        ObjectMessage message = context.createObjectMessage();
        message.setObject(body);
        doSend(destination, message);
    } catch (JMSException jmse) {
        throw Utils.convertToRuntimeException(jmse);
    }
    return this;
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:12,代碼來源:JMSProducerImpl.java

示例10: sendMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
private void sendMessage(String command, Serializable obj, String rashodCode) throws JMSException {
  ObjectMessage addMessage = session.createObjectMessage();
  addMessage.setStringProperty("operation", command);
  addMessage.setStringProperty("rashodCode", rashodCode);
  addMessage.setObject(obj);
  producer.send(addMessage);
}
 
開發者ID:unsftn,項目名稱:bisis-v4,代碼行數:8,代碼來源:RecordManagerImpl.java

示例11: sendMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public void sendMessage(ConnectionFactory connectionFactory, Queue queue, Serializable messageData) throws JMSException {
    Connection connection = connectionFactory.createConnection();
    Session session = connection.createSession(
            false,
            Session.AUTO_ACKNOWLEDGE);
    MessageProducer producer = session.createProducer(queue);
    ObjectMessage objectMessage = session.createObjectMessage();
    objectMessage.setObject(messageData);
    producer.send(objectMessage);
}
 
開發者ID:raidentrance,項目名稱:ejb3.1-certification,代碼行數:11,代碼來源:MessageHelper.java

示例12: sendResponseMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public void sendResponseMessage(Serializable object, String id) throws JMSException {
    ObjectMessage message = queuesession.createObjectMessage();
    message.setObject(object);
    if (id != null) {
        message.setJMSCorrelationID(id);
    }
    message.setJMSExpiration(3600 * 1000);
    producer.send(queue, message);
}
 
開發者ID:navisidhu,項目名稱:libreacs,代碼行數:10,代碼來源:Jms.java

示例13: sendCallMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public void sendCallMessage(Serializable object, String id, HostsLocal host/*String oui, String sn*/) throws JMSException {
    ObjectMessage msg = queuesession.createObjectMessage();
    msg.setJMSMessageID(id);
    msg.setJMSExpiration(3600 * 1000);
    msg.setObject(object);

    /*
    msg.setStringProperty("OUI", oui);
    msg.setStringProperty("SN", sn);
     */
    msg.setStringProperty("HWID", host.getHwid().toString());
    msg.setStringProperty("SN", host.getSerialno());

    producer.send(queue, msg);
}
 
開發者ID:navisidhu,項目名稱:libreacs,代碼行數:16,代碼來源:Jms.java

示例14: putBackMessageOnIndexerQueue

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
private boolean putBackMessageOnIndexerQueue(Message message) {
    if (message instanceof ObjectMessage) {
        Session session = null;
        Connection conn = null;
        try {
            Context jndiContext = getContext();
            ConnectionFactory qFactory = (ConnectionFactory) jndiContext
                    .lookup("jms/bss/indexerQueueFactory");
            conn = qFactory.createConnection();
            Queue queue = (Queue) jndiContext
                    .lookup("jms/bss/indexerQueue");
            session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);
            ObjectMessage msg = session.createObjectMessage();
            msg.setObject(((ObjectMessage) message).getObject());
            producer.send(msg);
            return true;
        } catch (Throwable e) {
            // This should not happen because the indexer queue is in the
            // local server. If it happens, than there's something terribly
            // wrong.
            throw new SaaSSystemException(e);
        } finally {
            closeSession(session);
            closeConnection(conn);
        }
    } else {
        return false;
    }
}
 
開發者ID:servicecatalog,項目名稱:development,代碼行數:31,代碼來源:IndexRequestListener.java

示例15: sendCompressedObjectMessageUsingOpenWire

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
private void sendCompressedObjectMessageUsingOpenWire() throws Exception {
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);

   final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);

   ObjectMessage objectMessage = session.createObjectMessage();
   objectMessage.setObject(TEXT);

   producer.send(objectMessage);
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:12,代碼來源:CompressedInteropTest.java


注:本文中的javax.jms.ObjectMessage.setObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。