• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ActiveMQBytesMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.activemq.command.ActiveMQBytesMessage的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBytesMessage类的具体用法?Java ActiveMQBytesMessage怎么用?Java ActiveMQBytesMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ActiveMQBytesMessage类属于org.apache.activemq.command包,在下文中一共展示了ActiveMQBytesMessage类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: transformToMap

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
/**
 * Transform an ActiveMQBytesMessage to a Map
 * 
 * @param msg - bytes message to transform
 * @return map object
 * @throws JMSException
 */
protected Map transformToMap(ActiveMQBytesMessage msg) throws JMSException {
    Properties props = new Properties();

    props.putAll(transformToMap((ActiveMQMessage)msg));

    long bodyLength = msg.getBodyLength();
    byte[] msgBody;
    int i = 0;
    // Create separate bytes messages
    for (i = 0; i < (bodyLength / Integer.MAX_VALUE); i++) {
        msgBody = new byte[Integer.MAX_VALUE];
        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody));
    }
    msgBody = new byte[(int)(bodyLength % Integer.MAX_VALUE)];
    props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody));

    return props;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:MapTransformFilter.java


示例2: testBytesMessageCompressionActiveMQ

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Test
public void testBytesMessageCompressionActiveMQ() throws Exception {
    sendAMQBytesMessage(TEXT);
    ActiveMQBytesMessage message = receiveAMQBytesMessage();
    int compressedSize = message.getContent().getLength();
    byte[] bytes = new byte[TEXT.getBytes("UTF8").length];
    message.readBytes(bytes);
    assertTrue(message.readBytes(new byte[255]) == -1);
    String rcvString = new String(bytes, "UTF8");
    assertEquals(TEXT, rcvString);
    assertTrue(message.isCompressed());

    sendAMQBytesMessage(TEXT, false);
    message = receiveAMQBytesMessage();
    int unCompressedSize = message.getContent().getLength();

    assertTrue("expected: compressed Size '" + compressedSize + "' < unCompressedSize '" + unCompressedSize + "'",
               compressedSize < unCompressedSize);
}
 
开发者ID:apache,项目名称:activemq-openwire,代码行数:20,代码来源:MessageCompressionTest.java


示例3: flushBuffer

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
private void flushBuffer() throws IOException {
    if (count != 0) {
        try {
            ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.writeBytes(buffer, 0, count);
            send(msg, false);
        } catch (JMSException e) {
            throw IOExceptionSupport.create(e);
        }
        count = 0;
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:13,代码来源:ActiveMQOutputStream.java


示例4: onMessageDispatch

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException {
    ActiveMQMessage message = (ActiveMQMessage)md.getMessage();
    if (ackMode == CLIENT_ACK) {
        synchronized (this) {
            dispatchedMessage.put(message.getMessageId(), md);
        }
    } else if (ackMode == INDIVIDUAL_ACK) {
        synchronized (this) {
            dispatchedMessage.put(message.getMessageId(), md);
        }
    } else if (ackMode == AUTO_ACK) {
        MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1);
        protocolConverter.getStompTransport().sendToActiveMQ(ack);
    }

    boolean ignoreTransformation = false;

    if (transformation != null && !( message instanceof ActiveMQBytesMessage ) ) {
        message.setReadOnlyProperties(false);
        message.setStringProperty(Stomp.Headers.TRANSFORMATION, transformation);
    } else {
        if (message.getStringProperty(Stomp.Headers.TRANSFORMATION) != null) {
            ignoreTransformation = true;
        }
    }

    StompFrame command = protocolConverter.convertMessage(message, ignoreTransformation);

    command.setAction(Stomp.Responses.MESSAGE);
    if (subscriptionId != null) {
        command.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, subscriptionId);
    }

    if (ackId != null) {
        command.getHeaders().put(Stomp.Headers.Message.ACK_ID, ackId);
    }

    protocolConverter.getStompTransport().sendToStomp(command);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:40,代码来源:StompSubscription.java


示例5: testBytesMessageCompression

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Test
public void testBytesMessageCompression() throws Exception {

   MessageConsumer consumer1 = remoteSession.createConsumer(included);
   MessageProducer producer = localSession.createProducer(included);
   producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

   waitForConsumerRegistration(localBroker, 1, included);

   StringBuilder payload = new StringBuilder("test-");
   for (int i = 0; i < 100; ++i) {
      payload.append(UUID.randomUUID().toString());
   }

   byte[] bytes = payload.toString().getBytes(StandardCharsets.UTF_8);

   BytesMessage test = localSession.createBytesMessage();
   test.writeBytes(bytes);
   producer.send(test);
   Message msg = consumer1.receive(RECEIVE_TIMEOUT_MILLS);
   assertNotNull(msg);
   ActiveMQBytesMessage message = (ActiveMQBytesMessage) msg;
   assertTrue(message.isCompressed());
   assertTrue(message.getContent().getLength() < bytes.length);

   byte[] result = new byte[bytes.length];
   assertEquals(bytes.length, message.readBytes(result));
   assertEquals(-1, message.readBytes(result));

   for (int i = 0; i < bytes.length; ++i) {
      assertEquals(bytes[i], result[i]);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:CompressionOverNetworkTest.java


示例6: testBrowseByteMessageFails

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Test
public void testBrowseByteMessageFails() throws Exception {
   ActiveMQBytesMessage bm = new ActiveMQBytesMessage();
   bm.writeBytes("123456".getBytes());
   Object result = OpenTypeSupport.convert(bm);
   LOG.info("result : " + result);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:OpenTypeSupportTest.java


示例7: receiveAMQBytesMessage

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
private ActiveMQBytesMessage receiveAMQBytesMessage() throws Exception {
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionURI);
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(getActiveMQQueue());
    ActiveMQBytesMessage rc = (ActiveMQBytesMessage) consumer.receive();
    connection.close();
    return rc;
}
 
开发者ID:apache,项目名称:activemq-openwire,代码行数:11,代码来源:MessageCompressionTest.java


示例8: getBody

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Override
public <T> T getBody(final Class<T> c) throws JMSException {
    final int len = (int) getBodyLength();
    if (len == 0) {
        return null;
    }
    final byte[] dst = new byte[len];
    if (ActiveMQBytesMessage.class.isInstance(message)) {
        System.arraycopy(ActiveMQBytesMessage.class.cast(message).getContent().getData(), 0, dst, 0, len);
    }
    return c.cast(dst);
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:WrappingByteMessage.java


示例9: onMessage

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Override
public void onMessage(Message message) {
	ActiveMQBytesMessage msg = (ActiveMQBytesMessage) message;
	byte[] data = msg.getContent().getData();
	processByteMessage(data);
}
 
开发者ID:xushaomin,项目名称:apple-jms,代码行数:7,代码来源:BaseMessageConsumer.java


示例10: createBytesMessage

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Override
public BytesMessage createBytesMessage() throws JMSException {

    return new ActiveMQBytesMessage();
}
 
开发者ID:DarkPhoenixs,项目名称:message-queue-client-framework,代码行数:6,代码来源:MessageConverterTest.java


示例11: fillBuffer

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
private void fillBuffer() throws IOException {
    if (eosReached || (buffer != null && buffer.length > pos)) {
        return;
    }
    try {
        while (true) {
            ActiveMQMessage m = receive();
            if (m != null && m.getDataStructureType() == CommandTypes.ACTIVEMQ_BYTES_MESSAGE) {
                // First message.
                long producerSequenceId = m.getMessageId().getProducerSequenceId();
                if (producerId == null) {
                    // We have to start a stream at sequence id = 0
                    if (producerSequenceId != 0) {
                        continue;
                    }
                    nextSequenceId++;
                    producerId = m.getMessageId().getProducerId();
                } else {
                    // Verify it's the next message of the sequence.
                    if (!m.getMessageId().getProducerId().equals(producerId)) {
                        throw new IOException("Received an unexpected message: invalid producer: " + m);
                    }
                    if (producerSequenceId != nextSequenceId++) {
                        throw new IOException("Received an unexpected message: expected ID: " + (nextSequenceId - 1) + " but was: " + producerSequenceId + " for message: " + m);
                    }
                }

                // Read the buffer in.
                ActiveMQBytesMessage bm = (ActiveMQBytesMessage)m;
                buffer = new byte[(int)bm.getBodyLength()];
                bm.readBytes(buffer);
                pos = 0;
                if (jmsProperties == null) {
                    jmsProperties = Collections.unmodifiableMap(new HashMap<String, Object>(bm.getProperties()));
                }
            } else {
                eosReached = true;
                if (jmsProperties == null) {
                    // no properties found
                    jmsProperties = Collections.emptyMap();
                }
            }
            return;
        }
    } catch (JMSException e) {
        eosReached = true;
        if (jmsProperties == null) {
            // no properties found
            jmsProperties = Collections.emptyMap();
        }
        throw IOExceptionSupport.create(e);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:54,代码来源:ActiveMQInputStream.java


示例12: getTypeName

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Override
protected String getTypeName() {
    return ActiveMQBytesMessage.class.getName();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:5,代码来源:OpenTypeSupport.java


示例13: createBytesMessage

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Override
public BytesMessage createBytesMessage() {
    return new ActiveMQBytesMessage();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:5,代码来源:ActiveMQJMSVendor.java


示例14: createObject

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
/**
 * @return a new object instance
 */
public DataStructure createObject() {
    return new ActiveMQBytesMessage();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:7,代码来源:ActiveMQBytesMessageMarshaller.java


示例15: createObject

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Override
public Object createObject() throws Exception {
   ActiveMQBytesMessage info = new ActiveMQBytesMessage();
   populateObject(info);
   return info;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:7,代码来源:ActiveMQBytesMessageTest.java


示例16: populateObject

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
@Override
protected void populateObject(Object object) throws Exception {
   super.populateObject(object);
   ActiveMQBytesMessage info = (ActiveMQBytesMessage) object;

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:7,代码来源:ActiveMQBytesMessageTest.java


示例17: testTransformMessage

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
/**
 * Tests transforming messages into ActiveMQ's message implementation.
 */
public void testTransformMessage() throws Exception {
   assertTrue("Transforming a BytesMessage message into an ActiveMQBytesMessage", ActiveMQMessageTransformation.transformMessage(new ActiveMQBytesMessage(), null) instanceof ActiveMQBytesMessage);

   assertTrue("Transforming a MapMessage message to an ActiveMQMapMessage", ActiveMQMessageTransformation.transformMessage(new ActiveMQMapMessage(), null) instanceof ActiveMQMapMessage);

   assertTrue("Transforming an ObjectMessage message to an ActiveMQObjectMessage", ActiveMQMessageTransformation.transformMessage(new ActiveMQObjectMessage(), null) instanceof ActiveMQObjectMessage);

   assertTrue("Transforming a StreamMessage message to an ActiveMQStreamMessage", ActiveMQMessageTransformation.transformMessage(new ActiveMQStreamMessage(), null) instanceof ActiveMQStreamMessage);

   assertTrue("Transforming a TextMessage message to an ActiveMQTextMessage", ActiveMQMessageTransformation.transformMessage(new ActiveMQTextMessage(), null) instanceof ActiveMQTextMessage);

   assertTrue("Transforming an ActiveMQMessage message to an ActiveMQMessage", ActiveMQMessageTransformation.transformMessage(new ActiveMQMessage(), null) instanceof ActiveMQMessage);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:MessageTransformationTest.java


示例18: createBytesMessage

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
/**
 * Creates a <CODE>BytesMessage</CODE> object. A <CODE>BytesMessage</CODE>
 * object is used to send a message containing a stream of uninterpreted
 * bytes.
 *
 * @return the an ActiveMQBytesMessage
 * @throws JMSException if the JMS provider fails to create this message due
 *                 to some internal error.
 */
public BytesMessage createBytesMessage() throws JMSException {
    ActiveMQBytesMessage message = new ActiveMQBytesMessage();
    configureMessage(message);
    return message;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:15,代码来源:ActiveMQSession.java


示例19: getDataStructureType

import org.apache.activemq.command.ActiveMQBytesMessage; //导入依赖的package包/类
/**
 * Return the type of Data Structure we marshal
 * @return short representation of the type data structure
 */
public byte getDataStructureType() {
    return ActiveMQBytesMessage.DATA_STRUCTURE_TYPE;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:8,代码来源:ActiveMQBytesMessageMarshaller.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OriginalType类代码示例发布时间:2022-05-22
下一篇:
Java Attribute类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap