Search in sources :

Example 1 with BytesMessageImpl

use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.

the class TopicAnnounceReceiver method run.

public void run() {
    if (!closed) {
        try {
            topicTransaction.commit();
            BytesMessageImpl msg = (BytesMessageImpl) messageEntry.getMessage();
            msg.reset();
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.topicManager.getName(), toString() + "/run, new message: " + msg);
            byte[] b = new byte[(int) msg.getBodyLength()];
            msg.readBytes(b);
            dis.reset();
            dis.setBuffer(b);
            VersionObject vo = (VersionObject) versionObjectFactory.createDumpable(dis.readInt());
            vo.readContent(dis);
            vo.accept(this);
            topicTransaction = topicReceiver.createTransaction(false);
            topicTransaction.registerMessageProcessor(this);
        } catch (Exception e) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.topicManager.getName(), toString() + "/ exception occurred: " + e + ", EXITING");
            try {
                ctx.queueManager.purgeQueue(topicQueue);
            } catch (Exception ignored) {
            }
            return;
        }
    }
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) SwiftletException(com.swiftmq.swiftlet.SwiftletException)

Example 2 with BytesMessageImpl

use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.

the class HeuristicHandler method messageToEntity.

private void messageToEntity(MessageImpl message, Entity entity) throws Exception {
    entity.setName(message.getStringProperty(PROP_SID));
    BytesMessageImpl msg = (BytesMessageImpl) message;
    byte[] b = new byte[(int) msg.getBodyLength()];
    msg.readBytes(b);
    DataByteArrayInputStream dis = new DataByteArrayInputStream(b);
    XidImpl xid = new XidImpl();
    xid.readContent(dis);
    entity.setUserObject(xid);
    entity.getProperty("xid").setValue(xid.toString());
    entity.getProperty("operation").setValue(msg.getStringProperty(PROP_OPER));
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) XidImpl(com.swiftmq.jms.XidImpl) DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream)

Example 3 with BytesMessageImpl

use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.

the class HeuristicHandler method entityToMessage.

private MessageImpl entityToMessage(Entity entity) throws Exception {
    XidImpl xid = (XidImpl) entity.getUserObject();
    DataByteArrayOutputStream dos = new DataByteArrayOutputStream();
    xid.writeContent(dos);
    BytesMessageImpl message = new BytesMessageImpl();
    message.setJMSDestination(new QueueImpl(HEURISTIC_QUEUE));
    message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
    message.setJMSPriority(Message.DEFAULT_PRIORITY);
    message.setJMSExpiration(Message.DEFAULT_TIME_TO_LIVE);
    message.setJMSMessageID(MSGID + IdGenerator.getInstance().nextId('/'));
    message.setStringProperty(PROP_OPER, (String) entity.getProperty(PROP_OPER).getValue());
    message.setStringProperty(PROP_SID, entity.getName());
    message.setIntProperty(PROP_IID, Integer.parseInt(entity.getName()));
    message.writeBytes(dos.getBuffer(), 0, dos.getCount());
    return message;
}
Also used : DataByteArrayOutputStream(com.swiftmq.tools.util.DataByteArrayOutputStream) BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) XidImpl(com.swiftmq.jms.XidImpl) QueueImpl(com.swiftmq.jms.QueueImpl)

Example 4 with BytesMessageImpl

use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-client by iitsoftware.

the class FileChunkRequest method toMessage.

public Message toMessage() throws JMSException {
    BytesMessage message = new BytesMessageImpl();
    fillMessage(message);
    message.setIntProperty(ProtocolFactory.DUMPID_PROP, ProtocolFactory.FILECHUNK_REQ);
    message.setIntProperty(CHUNKNO_PROP, chunkNo);
    message.setIntProperty(LENGTH_PROP, len);
    message.setBooleanProperty(LAST_PROP, last);
    message.writeBytes(chunk, 0, len);
    return message;
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) BytesMessage(javax.jms.BytesMessage)

Example 5 with BytesMessageImpl

use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.

the class BasicInboundTransformer method transform.

public MessageImpl transform(MessageWrap messageWrap, DestinationFactory destinationFactory) throws JMSException {
    MessageImpl msg = null;
    ContentHeaderProperties prop = messageWrap.getContentHeaderProperties();
    byte[] payload = getPayload(prop.getBodySize().intValue(), messageWrap.getBodyParts());
    if (prop.getContentType() != null && prop.getContentType().startsWith("text/")) {
        TextMessageImpl textMessage = new TextMessageImpl();
        try {
            textMessage.setText(new String(payload, "utf-8"));
        } catch (UnsupportedEncodingException e) {
            throw new JMSException(e.toString());
        }
        msg = textMessage;
    } else
        msg = new BytesMessageImpl(payload, payload.length);
    msg.setLongProperty(messageFormat, Util.MESSAGE_FORMAT);
    transformHeader(msg, prop, destinationFactory);
    return msg;
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) TextMessageImpl(com.swiftmq.jms.TextMessageImpl) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JMSException(javax.jms.JMSException) ContentHeaderProperties(com.swiftmq.amqp.v091.types.ContentHeaderProperties) MessageImpl(com.swiftmq.jms.MessageImpl) TextMessageImpl(com.swiftmq.jms.TextMessageImpl) BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl)

Aggregations

BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)26 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)5 QueueImpl (com.swiftmq.jms.QueueImpl)4 List (java.util.List)4 JMSException (javax.jms.JMSException)4 Endpoint (com.swiftmq.admin.mgmt.Endpoint)2 ContentHeaderProperties (com.swiftmq.amqp.v091.types.ContentHeaderProperties)2 ByteBuf (com.swiftmq.impl.mqtt.v311.netty.buffer.ByteBuf)2 TextMessageImpl (com.swiftmq.jms.TextMessageImpl)2 XidImpl (com.swiftmq.jms.XidImpl)2 StoreEntry (com.swiftmq.swiftlet.store.StoreEntry)2 Dumpable (com.swiftmq.tools.dump.Dumpable)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 BytesMessage (javax.jms.BytesMessage)2 Field (com.swiftmq.amqp.v091.types.Field)1 AMQPException (com.swiftmq.amqp.v100.client.AMQPException)1 Delivery (com.swiftmq.impl.amqp.amqp.v00_09_01.Delivery)1 MqttFixedHeader (com.swiftmq.impl.mqtt.v311.netty.handler.codec.mqtt.MqttFixedHeader)1 QueueIndexEntry (com.swiftmq.impl.store.standard.index.QueueIndexEntry)1