/** * Current messaging transport * @return messaging transport */ public Transport getMessagingTransport() { return channelFactory != null ? channelFactory.getMessagingTransport() : messagingTransport; }
/** * Current remoting transport * @return remoting transport */ public Transport getRemotingTransport() { return channelFactory != null ? channelFactory.getRemotingTransport() : remotingTransport; }
/** * Set the default channel builder * @param channelBuilder channel builder */ public void setDefaultChannelBuilder(ChannelBuilder channelBuilder) { this.defaultChannelBuilder = channelBuilder; if (channelFactory != null) channelFactory.setDefaultChannelBuilder(defaultChannelBuilder); }
channelFactory.setAliasRegistry(aliasRegistry); channelFactory.setScanPackageNames(packageNames); channelFactory.setDefaultChannelType(defaultChannelType); channelFactory.setRemotingTransport(remotingTransport); channelFactory.setMessagingTransport(messagingTransport); channelFactory.setMessagingTransport(me.getKey(), me.getValue()); channelFactory.setDefaultChannelBuilder(defaultChannelBuilder); channelFactory.setDefaultTimeToLive(defaultTimeToLive); channelFactory.start(); channelFactory.getRemotingTransport().setStatusHandler(statusHandler); for (Transport transport : channelFactory.getMessagingTransports().values()) transport.setStatusHandler(statusHandler); remotingChannel = channelFactory.newRemotingChannel("graniteamf", serverApp, 1); setupChannel(remotingChannel);
/** * Build a producer for the default channel type and destination * @param destination destination name * @param topic subtopic * @return producer */ public synchronized Producer getProducer(String destination, String topic) { return getProducer(destination, topic, channelFactory.getDefaultChannelType()); }
/** * Set the default channel type for messaging * @param channelType channel type */ public void setDefaultChannelType(String channelType) { this.defaultChannelType = channelType; if (channelFactory != null) channelFactory.setDefaultChannelType(defaultChannelType); }
/** * 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); }
/** * Return a messaging channel for the specified type * @param channelType channel type * @return messaging channel * @see org.granite.client.messaging.channel.ChannelType */ public MessagingChannel getMessagingChannel(String channelType) { MessagingChannel messagingChannel = messagingChannelsByType.get(channelType); if (messagingChannel != null) return messagingChannel; messagingChannel = channelFactory.newMessagingChannel(channelType, channelType + "amf", serverApp); messagingChannel.setSessionId(sessionId); setupChannel(messagingChannel); messagingChannelsByType.put(channelType, messagingChannel); return messagingChannel; }
/** * Build a consumer for the default channel type and destination * @param destination destination name * @param topic subtopic * @return consumer */ public synchronized Consumer getConsumer(String destination, String topic) { return getConsumer(destination, topic, channelFactory.getDefaultChannelType()); }
/** * Build a producer for the specified channel type and destination * @param destination destination name * @param topic subtopic * @param channelType channel type * @return producer */ public synchronized Producer getProducer(String destination, String topic, String channelType) { if (channelType == null) channelType = channelFactory.getDefaultChannelType(); MessagingChannel messagingChannel = getMessagingChannel(channelType); if (messagingChannel == null) throw new IllegalStateException("Channel not defined for server session"); String key = "P:" + destination + '@' + topic; Producer producer = (Producer)topicAgents.get(key); if (producer == null) { producer = serviceFactory.newProducer(messagingChannel, destination, topic); topicAgents.put(key, producer); } return producer; }
/** * Build a consumer for the specified channel type and destination * @param destination destination name * @param topic subtopic * @param channelType channel type * @return consumer */ public synchronized Consumer getConsumer(String destination, String topic, String channelType) { if (channelType == null) channelType = channelFactory.getDefaultChannelType(); MessagingChannel messagingChannel = getMessagingChannel(channelType); if (messagingChannel == null) throw new IllegalStateException("Channel not defined in server session for type " + channelType + ""); String key = "C:" + destination + '@' + topic; Consumer consumer = (Consumer)topicAgents.get(key); if (consumer == null) { consumer = serviceFactory.newConsumer(messagingChannel, destination, topic); consumer.addSubscriptionListener(consumerSubscriptionListener); topicAgents.put(key, consumer); } return consumer; }