Search in sources :

Example 61 with MessageImpl

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

the class MessageSenderJob method start.

public void start(Properties properties, JobTerminationListener jobTerminationListener) throws JobException {
    id = properties.getProperty(ctx.PARM);
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/start ...");
    try {
        MessageImpl msg = getMessage();
        String type = msg.getStringProperty(ctx.PROP_SCHED_DEST_TYPE).toLowerCase();
        String dest = msg.getStringProperty(ctx.PROP_SCHED_DEST);
        long expiration = 0;
        if (msg.propertyExists(ctx.PROP_SCHED_EXPIRATION))
            expiration = msg.getLongProperty(ctx.PROP_SCHED_EXPIRATION);
        List list = new ArrayList();
        for (Enumeration _enum = msg.getPropertyNames(); _enum.hasMoreElements(); ) {
            String name = (String) _enum.nextElement();
            if (name.startsWith("JMS_SWIFTMQ_SCHEDULER"))
                list.add(name);
        }
        for (int i = 0; i < list.size(); i++) msg.removeProperty((String) list.get(i));
        if (expiration > 0)
            msg.setJMSExpiration(System.currentTimeMillis() + expiration);
        msg.setJMSReplyTo(null);
        if (type.equals(ctx.QUEUE))
            sendToQueue(dest, msg);
        else
            sendToTopic(dest, msg);
    } catch (Exception e) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/start, exception=" + e);
        throw new JobException(e.getMessage(), e, false);
    }
    jobTerminationListener.jobTerminated();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/start done");
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) Enumeration(java.util.Enumeration) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) MessageImpl(com.swiftmq.jms.MessageImpl) JobException(com.swiftmq.swiftlet.scheduler.JobException)

Example 62 with MessageImpl

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

the class MessageSenderJob method copyMessage.

private MessageImpl copyMessage(MessageImpl msg) throws Exception {
    DataByteArrayOutputStream dbos = new DataByteArrayOutputStream();
    DataByteArrayInputStream dbis = new DataByteArrayInputStream();
    dbos.rewind();
    msg.writeContent(dbos);
    dbis.reset();
    dbis.setBuffer(dbos.getBuffer(), 0, dbos.getCount());
    MessageImpl msgCopy = MessageImpl.createInstance(dbis.readInt());
    msgCopy.readContent(dbis);
    return msgCopy;
}
Also used : DataByteArrayOutputStream(com.swiftmq.tools.util.DataByteArrayOutputStream) DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream) MessageImpl(com.swiftmq.jms.MessageImpl)

Example 63 with MessageImpl

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

the class FilePublishReply method toMessage.

public Message toMessage() throws JMSException {
    Message message = new MessageImpl();
    message.setIntProperty(ProtocolFactory.DUMPID_PROP, ProtocolFactory.FILEPUBLISH_REP);
    message.setIntProperty(CHUNKLENGTH_PROP, chunkLength);
    return fillMessage(message);
}
Also used : Message(javax.jms.Message) MessageImpl(com.swiftmq.jms.MessageImpl)

Example 64 with MessageImpl

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

the class FilePublishRequest method toMessage.

public Message toMessage() throws JMSException {
    Message message = new MessageImpl();
    fillMessage(message);
    message.setIntProperty(ProtocolFactory.DUMPID_PROP, ProtocolFactory.FILEPUBLISH_REQ);
    message.setStringProperty(REPLYQUEUE_PROP, replyQueue);
    message.setStringProperty(FILENAME_PROP, filename);
    if (username != null)
        message.setStringProperty(USERNAME_PROP, username);
    message.setLongProperty(SIZE_PROP, size);
    message.setLongProperty(EXPIRATION_PROP, expiration);
    message.setStringProperty(DIGESTTYPE_PROP, digestType);
    if (passwordHexDigest != null)
        message.setStringProperty(PWDHEXDIGEST_PROP, passwordHexDigest);
    message.setIntProperty(DELAFTERDL_PROP, deleteAfterNumberDownloads);
    message.setBooleanProperty(FILEISPRIVATE_PROP, fileIsPrivate);
    return message;
}
Also used : Message(javax.jms.Message) MessageImpl(com.swiftmq.jms.MessageImpl)

Example 65 with MessageImpl

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

the class FileDeleteReply method toMessage.

public Message toMessage() throws JMSException {
    Message message = new MessageImpl();
    message.setIntProperty(ProtocolFactory.DUMPID_PROP, ProtocolFactory.FILEDELETE_REP);
    return fillMessage(message);
}
Also used : Message(javax.jms.Message) MessageImpl(com.swiftmq.jms.MessageImpl)

Aggregations

MessageImpl (com.swiftmq.jms.MessageImpl)106 JMSException (javax.jms.JMSException)42 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)33 InvalidSelectorException (javax.jms.InvalidSelectorException)31 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)28 QueueImpl (com.swiftmq.jms.QueueImpl)21 DataByteArrayInputStream (com.swiftmq.tools.util.DataByteArrayInputStream)20 TopicImpl (com.swiftmq.jms.TopicImpl)17 MessageEntry (com.swiftmq.swiftlet.queue.MessageEntry)15 MessageIndex (com.swiftmq.swiftlet.queue.MessageIndex)15 RingBuffer (com.swiftmq.tools.collection.RingBuffer)14 InvalidDestinationException (javax.jms.InvalidDestinationException)14 List (java.util.List)13 EntityList (com.swiftmq.mgmt.EntityList)10 Message (javax.jms.Message)10 XidImpl (com.swiftmq.jms.XidImpl)6 DataByteArrayOutputStream (com.swiftmq.tools.util.DataByteArrayOutputStream)6 MessageSelector (com.swiftmq.ms.MessageSelector)5 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)4 ArrayList (java.util.ArrayList)4