public static void sendClientError(MessageBus bus, String queueId, String errorMessage, String additionalDetails) { try { MessageBuilder.createMessage() .toSubject(DefaultErrorCallback.CLIENT_ERROR_SUBJECT) .with("ErrorMessage", errorMessage) .with("AdditionalDetails", additionalDetails) .with(MessageParts.SessionID, queueId) .flag(RoutingFlag.NonGlobalRouting) .noErrorHandling().sendNowWith(bus); } catch (RuntimeException e) { // note: this is handled this way, because this is shared server and client code. if (e.getClass().getName().equals("org.jboss.errai.bus.server.QueueUnavailableException")) { // ignore. } throw e; } }
createMessage(CLIENT_ERROR_SUBJECT) .with(MessageParts.ErrorMessage, e.getMessage()) .with(MessageParts.AdditionalDetails, a.toString()) .with(MessageParts.Throwable, e) .noErrorHandling().sendNowWith(ErraiBus.get()); .toSubject(CLIENT_ERROR_SUBJECT) .with(MessageParts.ErrorMessage, e.getMessage()) .with(MessageParts.AdditionalDetails, a.toString()) .with(MessageParts.Throwable, e) .noErrorHandling().reply(); createMessage(CLIENT_ERROR_SUBJECT) .with(MessageParts.ErrorMessage, "Null exception reference") .with(MessageParts.AdditionalDetails, "No additional details") .noErrorHandling().sendNowWith(ErraiBus.get()); .toSubject(CLIENT_ERROR_SUBJECT) .with(MessageParts.ErrorMessage, "Null exception reference") .with(MessageParts.AdditionalDetails, "No additional details") .noErrorHandling().reply();
protected static void invokeDefaultErrorHandlers(final Throwable throwable) { MessageBuilder.createMessage(DefaultErrorCallback.CLIENT_ERROR_SUBJECT).signalling() .with(MessageParts.Throwable, throwable).defaultErrorHandling().sendNowWith(ErraiBus.get()); } }
@Override public void onUnsubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; if (messageQueues.isEmpty()) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteUnsubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
@Override public void onSubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteSubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
.toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.WebsocketChannelOpen) .with(MessageParts.WebSocketToken, reconnectionToken) .done().sendNowWith(ServerMessageBusImpl.this, false);
private void notifyPendingClients() { MessageBuilder.createMessage() .toSubject(subject) .command(ShoutboxCmd.SUBMIT_OFFER) .with(ShoutboxCmdParts.SUBJECT, subject) .with(ShoutboxCmdParts.PROVIDER, provider) .noErrorHandling().sendNowWith(bus); matchedClients.addAll(pendingClients); pendingClients.clear(); }
public void onClick(ClickEvent clickEvent) { Log.debug("ToolID: "+ tool.getId()); MessageBuilder.createMessage() .toSubject(Workspace.SUBJECT) .command(LayoutCommands.ActivateTool) .with(LayoutParts.TOOL, tool.getId()) .with(LayoutParts.TOOLSET, toolSetId) .noErrorHandling() .sendNowWith(ErraiBus.get()); } }
@Override public void onUnsubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; if (messageQueues.isEmpty()) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteUnsubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
protected static void invokeDefaultErrorHandlers(final Throwable throwable) { MessageBuilder.createMessage(DefaultErrorCallback.CLIENT_ERROR_SUBJECT).signalling() .with(MessageParts.Throwable, throwable).defaultErrorHandling().sendNowWith(ErraiBus.get()); } }
public void onClose(CloseEvent closeEvent) { createMessage() .toSubject("org.jboss.errai.WorkspaceLayout") .command(LayoutCommands.CloseTab) .with(LayoutParts.InstanceID, instanceId) .noErrorHandling().sendNowWith(ErraiBus.get()); }
public static Subscription subscribe(final String eventType, final AbstractCDIEventCallback<?> callback) { if (isRemoteCommunicationEnabled() && ErraiBus.get() instanceof ClientMessageBusImpl && ((ClientMessageBusImpl) ErraiBus.get()).getState().equals(BusState.CONNECTED)) { MessageBuilder.createMessage() .toSubject(CDI.SERVER_DISPATCHER_SUBJECT) .command(CDICommands.RemoteSubscribe) .with(CDIProtocol.BeanType, eventType) .with(CDIProtocol.Qualifiers, callback.getQualifiers()) .noErrorHandling().sendNowWith(ErraiBus.get()); } return subscribeLocal(eventType, callback, false); }
public static Subscription subscribe(final String eventType, final AbstractCDIEventCallback<?> callback) { if (isRemoteCommunicationEnabled() && ErraiBus.get() instanceof ClientMessageBusImpl && ((ClientMessageBusImpl) ErraiBus.get()).getState().equals(BusState.CONNECTED)) { MessageBuilder.createMessage() .toSubject(CDI.SERVER_DISPATCHER_SUBJECT) .command(CDICommands.RemoteSubscribe) .with(CDIProtocol.BeanType, eventType) .with(CDIProtocol.Qualifiers, callback.getQualifiers()) .noErrorHandling().sendNowWith(ErraiBus.get()); } return subscribeLocal(eventType, callback, false); }
public void closeTab(String instanceId) { MessageBuilder.createMessage() .toSubject(getInstanceSubject(instanceId)) .command(LayoutCommands.CloseTab) .with(LayoutParts.InstanceID, instanceId) .noErrorHandling().sendNowWith(ErraiBus.get()); }
@Override public void onSubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteSubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
@Override public void send(T value) { if (replyTo != null) { MessageBuilder.createMessage() .toSubject(toSubject) .with(MessageParts.ReplyTo, replyTo) .with(MessageParts.Value, value) .done().sendNowWith(messageBus); } else { MessageBuilder.createMessage() .toSubject(toSubject) .with(MessageParts.Value, value) .done().sendNowWith(messageBus); } }