* @param provider the metadata provider, null returns null
* @return the client
*/
@SuppressWarnings("deprecation")
protected LiveDataClient createLiveDataClient(final LiveDataMetaDataProvider provider) {
LiveDataMetaData metaData = provider.metaData();
URI jmsUri = metaData.getJmsBrokerUri();
if (metaData.getServerType() != LiveDataServerTypes.STANDARD || jmsUri == null) {
s_logger.warn("Unsupported live data server type " + metaData.getServerType() + " for " + metaData.getDescription() + " live data provider. This provider will not be available.");
return null;
}
JmsConnector jmsConnector = getJmsConnector();
if (!jmsConnector.getClientBrokerUri().equals(jmsUri)) {
JmsConnectorFactoryBean jmsFactory = new JmsConnectorFactoryBean(jmsConnector);
jmsFactory.setClientBrokerUri(jmsUri);
jmsConnector = jmsFactory.getObjectCreating();
}
JmsTemplate jmsTemplate = getJmsConnector().getJmsTemplateTopic();
JmsByteArrayRequestSender jmsSubscriptionRequestSender;
if (metaData.getJmsSubscriptionQueue() != null) {
JmsTemplate subscriptionRequestTemplate = getJmsConnector().getJmsTemplateQueue();
jmsSubscriptionRequestSender = new JmsByteArrayRequestSender(metaData.getJmsSubscriptionQueue(), subscriptionRequestTemplate);
} else {
jmsSubscriptionRequestSender = new JmsByteArrayRequestSender(metaData.getJmsSubscriptionTopic(), jmsTemplate);
}
ByteArrayFudgeRequestSender fudgeSubscriptionRequestSender = new ByteArrayFudgeRequestSender(jmsSubscriptionRequestSender);
JmsByteArrayRequestSender jmsEntitlementRequestSender = new JmsByteArrayRequestSender(metaData.getJmsEntitlementTopic(), jmsTemplate);
ByteArrayFudgeRequestSender fudgeEntitlementRequestSender = new ByteArrayFudgeRequestSender(jmsEntitlementRequestSender);
final JmsLiveDataClient liveDataClient = new JmsLiveDataClient(fudgeSubscriptionRequestSender,
fudgeEntitlementRequestSender, getJmsConnector(), OpenGammaFudgeContext.getInstance(), JmsLiveDataClient.DEFAULT_NUM_SESSIONS);
liveDataClient.setFudgeContext(OpenGammaFudgeContext.getInstance());
if (metaData.getJmsHeartbeatTopic() != null) {
JmsByteArrayMessageSender jmsHeartbeatSender = new JmsByteArrayMessageSender(metaData.getJmsHeartbeatTopic(), jmsTemplate);
liveDataClient.setHeartbeatMessageSender(jmsHeartbeatSender);
}
liveDataClient.start();
liveDataClient.registerMetrics(OpenGammaMetricRegistry.getSummaryInstance(), OpenGammaMetricRegistry.getDetailedInstance(), "LiveDataClient - " + provider.metaData().getDescription());
return liveDataClient;