Search in sources :

Example 1 with Message

use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.

the class TestTransaction method commit.

static void commit(MessageConsumer consumer) throws MQException {
    long old = System.currentTimeMillis();
    consumer.beginTransaction();
    consumer.receive(new OnMessage() {

        @Override
        public void onReceive(Message message) {
            System.out.println(message);
        }
    });
    consumer.commit();
    System.out.println("Time:" + (System.currentTimeMillis() - old));
}
Also used : OnMessage(com.generallycloud.baseio.container.jms.client.OnMessage) Message(com.generallycloud.baseio.container.jms.Message) OnMessage(com.generallycloud.baseio.container.jms.client.OnMessage)

Example 2 with Message

use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.

the class MQProducerServlet method doAccept.

@Override
public void doAccept(SocketSession session, ParamedProtobaseFuture future, MQSessionAttachment attachment) throws Exception {
    MQContext context = getMQContext();
    Message message = context.parse(future);
    context.offerMessage(message);
    future.write("1");
    session.flush(future);
}
Also used : Message(com.generallycloud.baseio.container.jms.Message)

Example 3 with Message

use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.

the class MQPublishServlet method doAccept.

@Override
public void doAccept(SocketSession session, ParamedProtobaseFuture future, MQSessionAttachment attachment) throws Exception {
    MQContext context = getMQContext();
    Message message = context.parse(future);
    context.publishMessage(message);
    future.write("1");
    session.flush(future);
}
Also used : Message(com.generallycloud.baseio.container.jms.Message)

Example 4 with Message

use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.

the class P2PProductLine method doLoop.

// FIXME 完善消息匹配机制
@Override
public void doLoop() {
    Message message = storage.poll(16);
    if (message == null) {
        return;
    }
    String queueName = message.getQueueName();
    ConsumerQueue consumerQueue = getConsumerQueue(queueName);
    List<Consumer> consumers = consumerQueue.getSnapshot();
    if (consumers.size() == 0) {
        filterUseless(message);
        return;
    }
    for (Consumer consumer : consumers) {
        try {
            consumer.push(message);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
            this.offerMessage(message);
        }
    }
    context.consumerMessage(message);
}
Also used : Message(com.generallycloud.baseio.container.jms.Message) IOException(java.io.IOException)

Example 5 with Message

use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.

the class SubscribeProductLine method doLoop.

// FIXME 完善消息匹配机制
@Override
public void doLoop() {
    Message message = storage.poll(16);
    if (message == null) {
        return;
    }
    String queueName = message.getQueueName();
    ConsumerQueue consumerQueue = getConsumerQueue(queueName);
    List<Consumer> consumers = consumerQueue.getSnapshot();
    if (consumers.size() == 0) {
        return;
    }
    for (Consumer consumer : consumers) {
        try {
            consumer.push(message);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
    }
    context.consumerMessage(message);
}
Also used : Message(com.generallycloud.baseio.container.jms.Message) IOException(java.io.IOException)

Aggregations

Message (com.generallycloud.baseio.container.jms.Message)15 OnMessage (com.generallycloud.baseio.container.jms.client.OnMessage)8 LoggerSocketSEListener (com.generallycloud.baseio.component.LoggerSocketSEListener)6 NioSocketChannelContext (com.generallycloud.baseio.component.NioSocketChannelContext)6 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)6 ServerConfiguration (com.generallycloud.baseio.configuration.ServerConfiguration)6 SocketChannelConnector (com.generallycloud.baseio.connector.SocketChannelConnector)6 FixedSession (com.generallycloud.baseio.container.FixedSession)6 SimpleIoEventHandle (com.generallycloud.baseio.container.SimpleIoEventHandle)6 MessageConsumer (com.generallycloud.baseio.container.jms.client.MessageConsumer)5 DefaultMessageConsumer (com.generallycloud.baseio.container.jms.client.impl.DefaultMessageConsumer)5 ProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ProtobaseProtocolFactory)4 ParamedProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory)2 TextByteMessage (com.generallycloud.baseio.container.jms.TextByteMessage)2 MessageBrowser (com.generallycloud.baseio.container.jms.client.MessageBrowser)2 IOException (java.io.IOException)2 ParamedProtobaseFuture (com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFuture)1 Parameters (com.generallycloud.baseio.component.Parameters)1 ErrorMessage (com.generallycloud.baseio.container.jms.ErrorMessage)1 MQException (com.generallycloud.baseio.container.jms.MQException)1