public static final String TMODEL_DESTINATION_NAME = TMODEL_KEY_BASE + "amqp.destination";
private void Fire() throws Exception {
String amqpURL = "amqp://guest:guest@clientid/?brokerlist='tcp://localhost:5672'";
UDDIClient client = new UDDIClient("META-INF/subscription-notification-client-uddi.xml");
UDDIClerk clerk = client.getClerk("default");
String base = "uddi:amqptestdomain:";
String lang = "en";
TModel destinationType = new TModel();
destinationType.setName(new Name("AMQP Destination Type", lang));
destinationType.getDescription().add(new Description("topicExchange, queue, etc", lang));
destinationType.setTModelKey(TMODEL_DESTINATION_TYPE);
TModel destinationName = new TModel();
destinationName.setName(new Name("AMQP Destination Name", lang));
destinationName.getDescription().add(new Description("The name of the topic or queue", lang));
destinationName.setTModelKey(TMODEL_DESTINATION_NAME);
TModel createKeyGenator = UDDIClerk.createKeyGenator(base + "keygenerator", "AMQP Test Key domain", lang);
BusinessEntity be = new BusinessEntity();
be.setBusinessKey(base + "business");
be.getName().add(new Name("AMQP Test callbacks", lang));
be.setBusinessServices(new BusinessServices());
BusinessService bs = new BusinessService();
bs.getName().add(new Name("AMQP Test service", lang));
bs.setBindingTemplates(new BindingTemplates());
bs.setBusinessKey(base + "business");
bs.setServiceKey(base + "service");
BindingTemplate bt = new BindingTemplate();
bt.setBindingKey(base + "binding");
bt.setServiceKey(base + "service");
bt.setAccessPoint(new AccessPoint(amqpURL, AccessPointType.END_POINT.toString()));
bt.setTModelInstanceDetails(new TModelInstanceDetails());
TModelInstanceInfo version = UDDIClerk.createServiceInterfaceVersion("1.0", lang);
bt.getTModelInstanceDetails().getTModelInstanceInfo().add(version);
TModelInstanceInfo transport = new TModelInstanceInfo();
transport.setTModelKey(UDDIConstants.TRANSPORT_AMQP);
bt.getTModelInstanceDetails().getTModelInstanceInfo().add(transport);
TModelInstanceInfo topic = new TModelInstanceInfo();
topic.setTModelKey(TMODEL_DESTINATION_TYPE);
topic.setInstanceDetails(new InstanceDetails());
topic.getInstanceDetails().setInstanceParms("amq.topic");
bt.getTModelInstanceDetails().getTModelInstanceInfo().add(topic);
TModelInstanceInfo name = new TModelInstanceInfo();
name.setTModelKey(TMODEL_DESTINATION_NAME);
name.setInstanceDetails(new InstanceDetails());
name.getInstanceDetails().setInstanceParms(TOPIC);
bt.getTModelInstanceDetails().getTModelInstanceInfo().add(name);
bs.getBindingTemplates().getBindingTemplate().add(bt);
be.getBusinessServices().getBusinessService().add(bs);
try {
System.out.println("Registering tModel");
clerk.register(createKeyGenator);
System.out.println("Registering destination type tmodel");
clerk.register(destinationType);
System.out.println("Registering destination name tmodel");
clerk.register(destinationName);
System.out.println("Registering business with callback definition");
clerk.register(be);
Properties p = new Properties();
p.setProperty("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
p.setProperty("connectionfactory.qpidConnectionfactory", amqpURL);
p.setProperty("destination." + TOPIC, "amq.topic");
System.out.println("Connecting to AMQP at " + amqpURL);
Context context = new InitialContext(p);
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("qpidConnectionfactory");
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = (Destination) context.lookup(TOPIC);
MessageConsumer consumer = session.createConsumer(destination);
consumer.setMessageListener(this);
System.out.println("Connected and listening...");
Subscription sub = new Subscription();
sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(1000));
sub.setBindingKey(base + "binding");
sub.setSubscriptionKey(base + "sub-fb");
sub.setSubscriptionFilter(new SubscriptionFilter());
sub.getSubscriptionFilter().setFindBusiness(new FindBusiness());
sub.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers());
sub.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
sub.getSubscriptionFilter().getFindBusiness().getName().add(new Name(UDDIConstants.WILDCARD, null));
Subscription subscriptionBiz = clerk.register(sub, clerk.getUDDINode().getApiNode());
System.out.println("Registered FindBusiness subscription key: " + (subscriptionBiz.getSubscriptionKey()) + " bindingkey: " + subscriptionBiz.getBindingKey());
sub = new Subscription();
sub.setSubscriptionKey(base + "sub-fs");
sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(1000));
sub.setBindingKey(base + "binding");
sub.setSubscriptionFilter(new SubscriptionFilter());
sub.getSubscriptionFilter().setFindService(new FindService());
sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
sub.getSubscriptionFilter().getFindService().getName().add(new Name(UDDIConstants.WILDCARD, null));
Subscription subscriptionSvc = clerk.register(sub, clerk.getUDDINode().getApiNode());
System.out.println("Registered FindService subscription key: " + (subscriptionSvc.getSubscriptionKey()) + " bindingkey: " + subscriptionSvc.getBindingKey());
sub = new Subscription();
sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(1000));
sub.setBindingKey(base + "binding");
sub.setSubscriptionKey(base + "sub-ft");
sub.setSubscriptionFilter(new SubscriptionFilter());
sub.getSubscriptionFilter().setFindTModel(new FindTModel());
sub.getSubscriptionFilter().getFindTModel().setFindQualifiers(new FindQualifiers());
sub.getSubscriptionFilter().getFindTModel().getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
sub.getSubscriptionFilter().getFindTModel().setName(new Name(UDDIConstants.WILDCARD, null));
Subscription subscriptionTM = clerk.register(sub, clerk.getUDDINode().getApiNode());
System.out.println("Registered FindTModel subscription key: " + (subscriptionTM.getSubscriptionKey()) + " bindingkey: " + subscriptionTM.getBindingKey());
System.out.println("Waiting for callbacks. Now would be a good time to launch either another program or juddi-gui to make some changes. Press any key to stop!");