当前位置: 首页>>代码示例>>Java>>正文


Java BytesMessage.setBooleanProperty方法代码示例

本文整理汇总了Java中javax.jms.BytesMessage.setBooleanProperty方法的典型用法代码示例。如果您正苦于以下问题:Java BytesMessage.setBooleanProperty方法的具体用法?Java BytesMessage.setBooleanProperty怎么用?Java BytesMessage.setBooleanProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jms.BytesMessage的用法示例。


在下文中一共展示了BytesMessage.setBooleanProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reply

import javax.jms.BytesMessage; //导入方法依赖的package包/类
/**
 * Replies to JMS client file query.
 * Sends the queried file if it is valid.
 * 
 * @param filename - File to be sent
 * @param replyQueue
 * @throws JMSException
 */
public void reply(String filename, Destination replyQueue) throws JMSException {
	messageProducer = session.createProducer(replyQueue);
	
	BytesMessage bytesMessage = session.createBytesMessage();
	
	boolean status = isValidFile(filename);
	bytesMessage.setBooleanProperty("status", status);
	
	if (status) {
		logger.info("Sending file: " + filename);
		
		try (InputStream inputStream = new FileInputStream(pathToRoot + "/" + filename)) {
			int c;
			while ((c = inputStream.read()) != -1) {
				bytesMessage.writeByte((byte) c);
			}
			messageProducer.send(bytesMessage);
		} catch (IOException e) {
			e.printStackTrace();
		}
	} else {
		logger.warning("File not found or invalid: " + filename);
	}
	
	messageProducer.send(bytesMessage);
}
 
开发者ID:marcelherd,项目名称:hochschule-mannheim,代码行数:35,代码来源:FileServer.java

示例2: testSubscribeWithMessageSentWithProperties

import javax.jms.BytesMessage; //导入方法依赖的package包/类
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
   conn.connect(defUser, defPass);
   subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);

   MessageProducer producer = session.createProducer(queue);
   BytesMessage message = session.createBytesMessage();
   message.setStringProperty("S", "value");
   message.setBooleanProperty("n", false);
   message.setByteProperty("byte", (byte) 9);
   message.setDoubleProperty("d", 2.0);
   message.setFloatProperty("f", (float) 6.0);
   message.setIntProperty("i", 10);
   message.setLongProperty("l", 121);
   message.setShortProperty("s", (short) 12);
   message.writeBytes("Hello World".getBytes(StandardCharsets.UTF_8));
   producer.send(message);

   ClientStompFrame frame = conn.receiveFrame(10000);
   Assert.assertNotNull(frame);
   Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
   Assert.assertEquals("value", frame.getHeader("S"));
   Assert.assertEquals("false", frame.getHeader("n"));
   Assert.assertEquals("9", frame.getHeader("byte"));
   Assert.assertEquals("2.0", frame.getHeader("d"));
   Assert.assertEquals("6.0", frame.getHeader("f"));
   Assert.assertEquals("10", frame.getHeader("i"));
   Assert.assertEquals("121", frame.getHeader("l"));
   Assert.assertEquals("12", frame.getHeader("s"));
   Assert.assertEquals("Hello World", frame.getBody());

   conn.disconnect();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:StompTest.java

示例3: testSubscribeWithMessageSentWithProperties

import javax.jms.BytesMessage; //导入方法依赖的package包/类
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
   conn.connect(defUser, defPass);

   subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO);

   MessageProducer producer = session.createProducer(queue);
   BytesMessage message = session.createBytesMessage();
   message.setStringProperty("S", "value");
   message.setBooleanProperty("n", false);
   message.setByteProperty("byte", (byte) 9);
   message.setDoubleProperty("d", 2.0);
   message.setFloatProperty("f", (float) 6.0);
   message.setIntProperty("i", 10);
   message.setLongProperty("l", 121);
   message.setShortProperty("s", (short) 12);
   message.writeBytes("Hello World".getBytes(StandardCharsets.UTF_8));
   producer.send(message);

   ClientStompFrame frame = conn.receiveFrame();
   Assert.assertNotNull(frame);

   Assert.assertTrue(frame.getHeader("S") != null);
   Assert.assertTrue(frame.getHeader("n") != null);
   Assert.assertTrue(frame.getHeader("byte") != null);
   Assert.assertTrue(frame.getHeader("d") != null);
   Assert.assertTrue(frame.getHeader("f") != null);
   Assert.assertTrue(frame.getHeader("i") != null);
   Assert.assertTrue(frame.getHeader("l") != null);
   Assert.assertTrue(frame.getHeader("s") != null);
   Assert.assertEquals("Hello World", frame.getBody());

   conn.disconnect();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:StompV11Test.java


注:本文中的javax.jms.BytesMessage.setBooleanProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。