当前位置: 首页>>代码示例>>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;未经允许,请勿转载。