@Override public MessagingChannel newMessagingChannel(String id, String uri) { try { MessagingChannel channel = newMessagingChannel(id, new URI(uri)); if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; } catch (URISyntaxException e) { throw new IllegalArgumentException("Bad uri: " + uri, e); } } }
/** * Set default time to live on all channels * @param timeToLive time to live in milliseconds */ public void setDefaultTimeToLive(long timeToLive) { defaultTimeToLive = timeToLive; if (channelFactory != null) channelFactory.setDefaultTimeToLive(timeToLive); for (MessagingChannel messagingChannel : messagingChannelsByType.values()) messagingChannel.setDefaultTimeToLive(timeToLive); if (remotingChannel != null) remotingChannel.setDefaultTimeToLive(timeToLive); }
@Override public MessagingChannel newMessagingChannel(String channelType, String id, URI uri) { Transport transport = getMessagingTransport(channelType); if (transport == null) throw new RuntimeException("No transport defined for channel type " + channelType + ", start the ChannelFactory first"); if (!transport.isStarted() && !transport.start()) throw new TransportException("Could not start messaging transport: " + transport); MessagingCodec<Message[]> codec = newMessagingCodec(Message[].class); for (ChannelBuilder builder : ServiceLoader.load(ChannelBuilder.class)) { MessagingChannel channel = builder.buildMessagingChannel(channelType, id, uri, transport, codec); if (channel != null) { if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; } } MessagingChannel channel = defaultChannelBuilder.buildMessagingChannel(channelType, id, uri, transport, codec); if (channel == null) throw new RuntimeException("Could not build channel for type " + channelType + " and uri " + uri); if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; }
@Override public MessagingChannel newMessagingChannel(String channelType, String id, URI uri) { Transport transport = getMessagingTransport(channelType); if (transport == null) throw new RuntimeException("No transport defined for channel type " + channelType + ", start the ChannelFactory first"); if (!transport.isStarted() && !transport.start()) throw new TransportException("Could not start messaging transport: " + transport); MessagingCodec<Message[]> codec = newMessagingCodec(Message[].class); for (ChannelBuilder builder : ServiceLoader.load(ChannelBuilder.class)) { MessagingChannel channel = builder.buildMessagingChannel(channelType, id, uri, transport, codec); if (channel != null) { if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; } } MessagingChannel channel = defaultChannelBuilder.buildMessagingChannel(channelType, id, uri, transport, codec); if (channel == null) throw new RuntimeException("Could not build channel for type " + channelType + " and uri " + uri); if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; }
@Override public MessagingChannel newMessagingChannel(String channelType, String id, ServerApp serverApp) { Transport transport = getMessagingTransport(channelType); if (transport == null) throw new RuntimeException("No transport defined for channel type " + channelType + ", start the ChannelFactory first"); if (!transport.isStarted() && !transport.start()) throw new TransportException("Could not start messaging transport: " + transport); MessagingCodec<Message[]> codec = newMessagingCodec(Message[].class); for (ChannelBuilder builder : ServiceLoader.load(ChannelBuilder.class)) { MessagingChannel channel = builder.buildMessagingChannel(channelType, id, serverApp, transport, codec); if (channel != null) { if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; } } MessagingChannel channel = defaultChannelBuilder.buildMessagingChannel(channelType, id, serverApp, transport, codec); if (channel == null) throw new RuntimeException("Could not build channel for type " + channelType + " and server " + serverApp.getServerName()); if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; }
@Override public MessagingChannel newMessagingChannel(String channelType, String id, ServerApp serverApp) { Transport transport = getMessagingTransport(channelType); if (transport == null) throw new RuntimeException("No transport defined for channel type " + channelType + ", start the ChannelFactory first"); if (!transport.isStarted() && !transport.start()) throw new TransportException("Could not start messaging transport: " + transport); MessagingCodec<Message[]> codec = newMessagingCodec(Message[].class); for (ChannelBuilder builder : ServiceLoader.load(ChannelBuilder.class)) { MessagingChannel channel = builder.buildMessagingChannel(channelType, id, serverApp, transport, codec); if (channel != null) { if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; } } MessagingChannel channel = defaultChannelBuilder.buildMessagingChannel(channelType, id, serverApp, transport, codec); if (channel == null) throw new RuntimeException("Could not build channel for type " + channelType + " and server " + serverApp.getServerName()); if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; }