private RPCMessageBus(MessageBusParams mbusParams, RPCNetwork network, String routingCfgId) { this(new MessageBus(network, mbusParams), network, routingCfgId); }
@Override public Sender createSender(ReplyHandler replyHandler, VisitorParameters visitorParameters) { messageBus.setMaxPendingCount(0); SourceSessionParams sessionParams = createSourceSessionParams(visitorParameters); return new MessageBusSender(messageBus.createSourceSession(replyHandler, sessionParams)); } }
@Override protected void destroy() { log.log(LogLevel.DEBUG, "Destroying shared message bus."); mbus.destroy(); }
@Override public void deliverMessage(Message msg, String session) { MessageHandler msgHandler = sessions.get(session); if (msgHandler == null) { deliverError(msg, ErrorCode.UNKNOWN_SESSION, "Session '" + session + "' does not exist."); } else if (!checkPending(msg)) { deliverError(msg, ErrorCode.SESSION_BUSY, "Session '" + net.getConnectionSpec() + "/" + session + "' is busy, try again later."); } else { msn.deliverMessage(msg, msgHandler); } }
private RemoteClient(Slobrok slobrok, String slobrokId, Protocol protocol) { this.slobrok = slobrok; this.slobrokId = slobrok != null ? slobrok.configId() : slobrokId; mbus = new MessageBus(new RPCNetwork(new RPCNetworkParams().setSlobrokConfigId(this.slobrokId)), new MessageBusParams().addProtocol(protocol)); session = mbus.createSourceSession(new SourceSessionParams().setThrottlePolicy(null).setReplyHandler(queue)); }
private RemoteServer(Slobrok slobrok, String slobrokId, Protocol protocol, String identity) { this.slobrok = slobrok; this.slobrokId = slobrok != null ? slobrok.configId() : slobrokId; mbus = new MessageBus(new RPCNetwork(new RPCNetworkParams() .setSlobrokConfigId(this.slobrokId) .setIdentity(new Identity(identity))), new MessageBusParams().addProtocol(protocol)); session = mbus.createDestinationSession(new DestinationSessionParams().setMessageHandler(queue)); }
@Override public Receiver createReceiver(MessageHandler messageHandler, String sessionName) { DestinationSessionParams destinationParams = createDestinationParams(messageHandler, sessionName); return new MessageBusReceiver(messageBus.createDestinationSession(destinationParams)); } }
/** * <p>This is a convenience method to call {@link * #createSourceSession(SourceSessionParams)} with default values for the * {@link SourceSessionParams} object.</p> * * @param handler The reply handler to receive the replies for the session. * @return The created session. */ public SourceSession createSourceSession(ReplyHandler handler) { return createSourceSession(new SourceSessionParams().setReplyHandler(handler)); }
/** * <p>Returns a named routing table, may return null.</p> * * @param name The name of the routing table to return. * @return The routing table object. */ public RoutingTable getRoutingTable(Utf8String name) { return getRoutingTable(name.toString()); }
/** * Returns the connection spec string for this session. This returns a combination of the owning message bus' own * spec string and the name of this session. * * @return The connection string. */ public String getConnectionSpec() { return mbus.getConnectionSpec() + "/" + name; }
public SharedIntermediateSession(SharedMessageBus mbus, IntermediateSessionParams params) { if (params.getReplyHandler() != null) { throw new IllegalArgumentException("Reply handler must be null."); } this.msgHandler.set(params.getMessageHandler()); this.session = mbus.messageBus().createIntermediateSession(params.setReplyHandler(this) .setMessageHandler(this)); this.mbusReference = mbus.refer(); }
@Override public void handleMessage(Message msg) { if (resender != null && msg.hasBucketSequence()) { deliverError(msg, ErrorCode.SEQUENCE_ERROR, "Bucket sequences not supported when resender is enabled."); return; } SendProxy proxy = new SendProxy(this, net, resender); msn.deliverMessage(msg, proxy); }
/** * Creates a message bus visitor destination session. * * @param params the parameters for the visitor destination session * @param bus the message bus to use */ public MessageBusVisitorDestinationSession(VisitorDestinationParameters params, MessageBus bus) { this.params = params; session = bus.createDestinationSession(params.getSessionName(), true, this); params.getDataHandler().setSession(this); }
/** * <p>This is a convenience method to call {@link * #createSourceSession(SourceSessionParams)} by first assigning the reply * handler to the parameter object.</p> * * @param handler The reply handler to receive the replies for the session. * @param params The parameters to control the session. * @return The created session. */ public SourceSession createSourceSession(ReplyHandler handler, SourceSessionParams params) { return createSourceSession(new SourceSessionParams(params).setReplyHandler(handler)); }
public static MessageBusVisitorSession createForMessageBus(final MessageBus mbus, final ScheduledExecutorService scheduledExecutorService, final VisitorParameters params) throws ParseException { final AsyncTaskExecutor executor = new ThreadAsyncTaskExecutor(scheduledExecutorService); final MessageBusSenderFactory senderFactory = new MessageBusSenderFactory(mbus); final MessageBusReceiverFactory receiverFactory = new MessageBusReceiverFactory(mbus); final RoutingTable table = mbus.getRoutingTable(DocumentProtocol.NAME); return new MessageBusVisitorSession(params, executor, senderFactory, receiverFactory, table); }
/** * Returns the connection spec string for this session. This returns a combination of the owning message bus' own * spec string and the name of this session. * * @return The connection string. */ public String getConnectionSpec() { return mbus.getConnectionSpec() + "/" + name; }
/** * <p>This is a convenience method to call {@link * #createIntermediateSession(IntermediateSessionParams)} with default * values for the {@link IntermediateSessionParams} object.</p> * * @param name The local unique name for the created session. * @param broadcastName Whether or not to broadcast this session's name on * the network. * @param msgHandler The handler to receive the messages for the session. * @param replyHandler The handler to received the replies for the session. * @return The created session. */ public IntermediateSession createIntermediateSession(String name, boolean broadcastName, MessageHandler msgHandler, ReplyHandler replyHandler) { return createIntermediateSession( new IntermediateSessionParams() .setName(name) .setBroadcastName(broadcastName) .setMessageHandler(msgHandler) .setReplyHandler(replyHandler)); }
public SharedDestinationSession(SharedMessageBus mbus, DestinationSessionParams params) { this.mbus = mbus; this.msgHandler.set(params.getMessageHandler()); this.session = mbus.messageBus().createDestinationSession(params.setMessageHandler(this)); this.mbusReference = mbus.refer(); }
/** * Create a new test server. * * @param mbusParams The parameters for mesasge bus. * @param netParams The parameters for the rpc network. */ public TestServer(MessageBusParams mbusParams, RPCNetworkParams netParams) { net = new VersionedRPCNetwork(netParams); mb = new MessageBus(net, mbusParams); }
public SharedSourceSession(SharedMessageBus mbus, SourceSessionParams params) { if (params.getReplyHandler() != null) { throw new IllegalArgumentException("Reply handler must be null."); } this.mbus = mbus; this.session = mbus.messageBus().createSourceSession(params.setReplyHandler(this)); this.mbusReference = mbus.refer(); }