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


Java ObjectMessage.setStringProperty方法代碼示例

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


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

示例1: publish

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
private static void publish(String destination, Serializable object, String contentType) throws Exception {
   Connection conn = createConnection();
   Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Destination dest = session.createQueue(destination);

   try {
      assertNotNull("Destination was null", dest);
      MessageProducer producer = session.createProducer(dest);
      ObjectMessage message = session.createObjectMessage();

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

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

示例2: publish

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public static void publish(String dest, Serializable object, String contentType) 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);
      }
      message.setObject(object);

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

示例3: 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

示例4: publish

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public static void publish(String destination, Serializable object, String contentType) throws Exception {
   BindingRegistry reg = server.getRegistry();
   ConnectionFactory factory = (ConnectionFactory) reg.lookup("ConnectionFactory");
   Connection conn = factory.createConnection();
   Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Destination dest = session.createQueue(destination);

   try {
      Assert.assertNotNull("Destination was null", dest);
      MessageProducer producer = session.createProducer(dest);
      ObjectMessage message = session.createObjectMessage();

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

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

示例5: 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

示例6: 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

示例7: 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

示例8: sendMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public void sendMessage(CustomerOrder customerOrder) {
    ObjectMessage msgObj = context.createObjectMessage();

    try {
        msgObj.setObject(customerOrder);
        msgObj.setStringProperty("OrderID", String.valueOf(customerOrder.getId()));

        context.createProducer().send(queue, msgObj);
    } catch (JMSException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:evgeniyosipov,項目名稱:facshop,代碼行數:13,代碼來源:OrderJMSManager.java

示例9: sendObjectMessageAndSetTime

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
/**
 * 定時發送
 * @param session
 * @param producer
 * @throws Exception
 */
public static void sendObjectMessageAndSetTime(Session session, MessageProducer producer) throws Exception {
	for (int i = 1; i <= SEND_NUMBER; i++) {
		ObjectMessage objMsg = session.createObjectMessage();
		// 類型
		objMsg.setStringProperty("type", MESSAGE_TYPE);
		
		// push發送配置
		PushConfig config = new PushConfig();
		//config.setMobile(""); // 按手機號
		// config.setUuid(""); // uuid 按設備唯一標示
		config.setUid(662281); // 按uid
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			config.setPush_time(sdf.parse("2016-01-28 17:01:00")); // 設置定期推送時間
			//config.setExpiration_interval(86400L); // 消息過期的相對時間,從調用 API 的時間開始算起,單位是「秒」
			//config.setExpiration_time(sdf.parse("2016-01-28 14:35:00"));// 消息過期的絕對日期時間
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		PushMessage msg = new PushMessage();
		msg.setTitle("push title");
		msg.setAlert("通過mq發送"); // 如果隻是通知消息,設置alert即可
		//msg.setUrl("push url");
		config.setPushMessage(msg);
		
		objMsg.setObject(config);
		producer.send(objMsg);
	}
}
 
開發者ID:toulezu,項目名稱:play,代碼行數:38,代碼來源:PushSender.java

示例10: sendObjectMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
/**
 * 發送 PushMessage 對象
 * @param session
 * @param producer
 * @throws Exception
 */
public static void sendObjectMessage(Session session, MessageProducer producer) throws Exception {
	for (int i = 1; i <= SEND_NUMBER; i++) {
		ObjectMessage objMsg = session.createObjectMessage();
		// 類型
		objMsg.setStringProperty("type", MESSAGE_TYPE);
		
		// push發送配置
		PushConfig config = new PushConfig();
		//config.setMobile(""); // 按手機號
		// config.setUuid(""); // uuid 按設備唯一標示
		config.setUid(662281); // 按uid
		
		/*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			config.setPush_time(sdf.parse("2016-01-27 14:57:00")); // 設置定期推送時間
			//config.setExpiration_interval(86400L); // 消息過期的相對時間,從調用 API 的時間開始算起,單位是「秒」
			config.setExpiration_time(sdf.parse("2016-01-28 14:35:00"));// 消息過期的絕對日期時間
		} catch (Exception e) {
			e.printStackTrace();
		}*/
		
		PushMessage msg = new PushMessage();
		//msg.setTitle("push title");
		msg.setAlert("通過mq發送"); // 如果隻是通知消息,設置alert即可
		//msg.setUrl("push url");
		config.setPushMessage(msg);
		
		objMsg.setObject(config);
		producer.send(objMsg);
	}
}
 
開發者ID:toulezu,項目名稱:play,代碼行數:38,代碼來源:PushSender.java

示例11: createConnectionAndSendMessage

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
public void createConnectionAndSendMessage(String ipAddress) throws JMSException {

		Connection connection = connectionFactory.createConnection();
		connection.start();

		Session topicSession = connection.createSession(false, AUTO_ACKNOWLEDGE);

		MessageProducer producer = topicSession.createProducer(topic);
		producer.setDeliveryMode(PERSISTENT);

		ObjectMessage message = topicSession.createObjectMessage();

		BUSStop busStop = new BUSStop();
		busStop.setName("Rome");

		message.setStringProperty("s_id", "Sample");
		message.setObject((Serializable) busStop);

		producer.send(message);
		logger.info("message sent successfully");
	}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:22,代碼來源:Publisher.java

示例12: testSendEmptyMessages

import javax.jms.ObjectMessage; //導入方法依賴的package包/類
@Test
public void testSendEmptyMessages() throws Exception {
   Queue dest = new ActiveMQQueue(queueName);

   QueueSession defaultQueueSession =  connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
   QueueSender defaultSender = defaultQueueSession.createSender(dest);
   defaultSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
   connection.start();

   Message msg = defaultQueueSession.createMessage();
   msg.setStringProperty("testName", "testSendEmptyMessages");
   defaultSender.send(msg);

   QueueReceiver queueReceiver = defaultQueueSession.createReceiver(dest);
   assertNotNull("Didn't receive message", queueReceiver.receive(1000));

   //bytes
   BytesMessage bytesMessage = defaultQueueSession.createBytesMessage();
   bytesMessage.setStringProperty("testName", "testSendEmptyMessages");
   defaultSender.send(bytesMessage);
   assertNotNull("Didn't receive message", queueReceiver.receive(1000));

   //map
   MapMessage mapMessage = defaultQueueSession.createMapMessage();
   mapMessage.setStringProperty("testName", "testSendEmptyMessages");
   defaultSender.send(mapMessage);
   assertNotNull("Didn't receive message", queueReceiver.receive(1000));

   //object
   ObjectMessage objMessage = defaultQueueSession.createObjectMessage();
   objMessage.setStringProperty("testName", "testSendEmptyMessages");
   defaultSender.send(objMessage);
   assertNotNull("Didn't receive message", queueReceiver.receive(1000));

   //stream
   StreamMessage streamMessage = defaultQueueSession.createStreamMessage();
   streamMessage.setStringProperty("testName", "testSendEmptyMessages");
   defaultSender.send(streamMessage);
   assertNotNull("Didn't receive message", queueReceiver.receive(1000));

   //text
   TextMessage textMessage = defaultQueueSession.createTextMessage();
   textMessage.setStringProperty("testName", "testSendEmptyMessages");
   defaultSender.send(textMessage);
   assertNotNull("Didn't receive message", queueReceiver.receive(1000));
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:47,代碼來源:SimpleOpenWireTest.java


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