public static Message decodeCommandMessage(final EJValue value) { return CommandMessage.createWithParts(decodePayloadMap(value)) .setResource(RequestDispatcher.class.getName(), requestDispatcherProvider) .setResource("Session", clientSession); }
@Override public void onUnsubscribe(final SubscriptionEvent event) { final String subject = event.getSubject(); if (subject.endsWith(":RespondTo:RPC") || subject.endsWith(":Errors:RPC")) { return; } encodeAndTransmit(CommandMessage.create() .toSubject(BuiltInServices.ServerBus.name()).command(RemoteUnsubscribe) .set(Subject, subject).set(PriorityProcessing, "1")); } });
/** * Creates a new CommandMessage with no parts and no provided parts. * * @return a new instance of CommandMessage. */ public static CommandMessage create() { return new CommandMessage(); }
private Message createWhoHandlesMessage(final String sessionId, final String subject, final String messageId) { return CommandMessage.create() .set(ToSubject, CLUSTER_SERVICE) .set(CommandType, ClusterCommands.WhoHandles.name()) .set(ClusterParts.SessId, sessionId) .set(BusId, busId) .set(Subject, subject) .set(MessageId, messageId); }
public static void fireEvent(final boolean local, final Object payload, final Annotation... qualifiers) { if (payload == null) return; final Object beanRef; if (payload instanceof WrappedPortable) { beanRef = ((WrappedPortable) payload).unwrap(); if (beanRef == null) return; } else { beanRef = payload; } final Map<String, Object> messageMap = new HashMap<>(); messageMap.put(MessageParts.CommandType.name(), CDICommands.CDIEvent.name()); messageMap.put(CDIProtocol.BeanType.name(), beanRef.getClass().getName()); messageMap.put(CDIProtocol.BeanReference.name(), beanRef); messageMap.put(CDIProtocol.FromClient.name(), "1"); if (qualifiers != null && qualifiers.length > 0) { messageMap.put(CDIProtocol.Qualifiers.name(), getQualifiersPart(qualifiers)); } consumeEventFromMessage(CommandMessage.createWithParts(messageMap)); if (isRemoteCommunicationEnabled()) { final CommandMessage withParts = CommandMessage.createWithParts(messageMap); messageMap.put(MessageParts.ToSubject.name(), SERVER_DISPATCHER_SUBJECT); fireOnSubscribe(beanRef.getClass().getName(), withParts); } }
public static Message decodeAndDemarshall(String json) { Map<String, Object> parts = ErraiProtocolEnvelopeMarshaller.INSTANCE.demarshall(JSONDecoder.decode(json), new DecodingSession(MappingContextSingleton.get())); if (parts == null) return CommandMessage.create(); return CommandMessage.createWithParts(parts); } }
@Override public Message get() { return CommandMessage.create(); } };
@SuppressWarnings("unchecked") public static Message createCommandMessage(QueueSession session, String json) { if (json.length() == 0) return null; Message msg = createWithPartsFromRawMap(ErraiProtocolEnvelopeMarshaller.INSTANCE.demarshall(JSONDecoder.decode(json), new DecodingSession(MappingContextSingleton.get()))) .setResource("Session", session) .setResource("SessionID", session.getSessionId()); msg.setFlag(RoutingFlag.FromRemote); return msg; }
@Override public String toString() { return buildDescription(); }
public static void fireEvent(final boolean local, final Object payload, final Annotation... qualifiers) { if (payload == null) return; final Object beanRef; if (payload instanceof WrappedPortable) { beanRef = ((WrappedPortable) payload).unwrap(); if (beanRef == null) return; } else { beanRef = payload; } final Map<String, Object> messageMap = new HashMap<>(); messageMap.put(MessageParts.CommandType.name(), CDICommands.CDIEvent.name()); messageMap.put(CDIProtocol.BeanType.name(), beanRef.getClass().getName()); messageMap.put(CDIProtocol.BeanReference.name(), beanRef); messageMap.put(CDIProtocol.FromClient.name(), "1"); if (qualifiers != null && qualifiers.length > 0) { messageMap.put(CDIProtocol.Qualifiers.name(), getQualifiersPart(qualifiers)); } consumeEventFromMessage(CommandMessage.createWithParts(messageMap)); if (isRemoteCommunicationEnabled()) { final CommandMessage withParts = CommandMessage.createWithParts(messageMap); messageMap.put(MessageParts.ToSubject.name(), SERVER_DISPATCHER_SUBJECT); fireOnSubscribe(beanRef.getClass().getName(), withParts); } }
public static Message decodeAndDemarshall(String json) { Map<String, Object> parts = ErraiProtocolEnvelopeMarshaller.INSTANCE.demarshall(JSONDecoder.decode(json), new DecodingSession(MappingContextSingleton.get())); if (parts == null) return CommandMessage.create(); return CommandMessage.createWithParts(parts); } }
private Message createInvalidRouteMessage(final String sessionId, final String subject, final String messageId) { return CommandMessage.create() .set(ToSubject, CLUSTER_SERVICE) .set(CommandType, ClusterCommands.InvalidRoute.name()) .set(SessId, sessionId) .set(Subject, subject) .set(MessageId, messageId) .set(BusId, busId); }
/** * Creates an <tt>AbstractRemoteCallBuilder</tt> to construct a call. * * @return an instance of <tt>AbstractRemoteCallBuilder</tt> */ public static DefaultRemoteCallBuilder createCall() { return new DefaultRemoteCallBuilder(CommandMessage.create()); }
@SuppressWarnings("unchecked") public static Message createCommandMessage(QueueSession session, String json) { if (json.length() == 0) return null; Message msg = createWithPartsFromRawMap(ErraiProtocolEnvelopeMarshaller.INSTANCE.demarshall(JSONDecoder.decode(json), new DecodingSession(MappingContextSingleton.get()))) .setResource("Session", session) .setResource("SessionID", session.getSessionId()); msg.setFlag(RoutingFlag.FromRemote); return msg; }
@Override public String toString() { return buildDescription(); }
public static Message uglyReEncode(String message) { if (message == null) return null; Map<String, Object> parts = ErraiProtocolEnvelopeMarshaller.INSTANCE.demarshall(JSONDecoder.decode(message), new DecodingSession(MappingContextSingleton.get())); return CommandMessage.createWithParts(parts); }
@SuppressWarnings("unchecked") private static Message from(Map parts, QueueSession session, HttpServletRequest request) { Message msg = createWithParts(parts) .setResource("Session", session) .setResource("SessionID", session.getSessionId()) .setResource(HttpServletRequest.class.getName(), request); msg.setFlag(RoutingFlag.FromRemote); return msg; } }
@Override public void onSubscribe(final SubscriptionEvent event) { final String subject = event.getSubject(); if (event.isLocalOnly() || subject.startsWith("local:") || remotes.containsKey(subject)) { return; } if (subject.endsWith(":RespondTo:RPC") || subject.endsWith(":Errors:RPC")) { return; } if (event.isNew()) { encodeAndTransmit(CommandMessage.create() .toSubject(BuiltInServices.ServerBus.name()).command(RemoteSubscribe) .set(Subject, subject).set(PriorityProcessing, "1")); } } });