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


Java ActiveMQBytesMessage类代码示例

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


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


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