本文整理匯總了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);
}
示例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();
}
示例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();
}