• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JCSMPSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.solacesystems.jcsmp.JCSMPSession的典型用法代码示例。如果您正苦于以下问题:Java JCSMPSession类的具体用法?Java JCSMPSession怎么用?Java JCSMPSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JCSMPSession类属于com.solacesystems.jcsmp包,在下文中一共展示了JCSMPSession类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ProducerThread

import com.solacesystems.jcsmp.JCSMPSession; //导入依赖的package包/类
public ProducerThread(String jobId, List<WorkInstance> workQueue,
		JCSMPSession session, Destination destForPublish, long msgRate,
		JobRequestStats jobStatus, GlobalStats globalStats) {
	this.jobId = jobId;
	this.workQueue = workQueue;
	this.session = session;
	this.destForPublish = destForPublish;
	this.msgRate = msgRate;
	this.jobStatus = jobStatus;
	this.globalStats = globalStats;
}
 
开发者ID:SolaceLabs,项目名称:sl-cf-solace-messaging-demo,代码行数:12,代码来源:ProducerThread.java


示例2: run

import com.solacesystems.jcsmp.JCSMPSession; //导入依赖的package包/类
public void run(String[] args) {

	try {

        System.out.println("OutputProxy initializing...");

        // Create a JCSMP Session
        JCSMPProperties properties = new JCSMPProperties();
        properties.setProperty(JCSMPProperties.HOST, args[0]); 		// msg-backbone ip:port
        properties.setProperty(JCSMPProperties.VPN_NAME, args[1]); 	// message-vpn
        properties.setProperty(JCSMPProperties.USERNAME, args[2]); 	// client-username (assumes no password)
	String t = args[3];
	Topic topic = JCSMPFactory.onlyInstance().createTopic(t);       // topic to subscribe to stream
	String host = args[4];						// redirect udp stream to this host
	port = Integer.parseInt(args[5]);				// redirect udp stream to this port	
	verbose = args[6];	   					// verbose
	
        session = JCSMPFactory.onlyInstance().createSession(properties);

        session.connect();

        Queue queue = session.createTemporaryQueue();

        FlowReceiver receiver = session.createFlow(queue, null, this);

        session.addSubscription(queue,topic,JCSMPSession.WAIT_FOR_CONFIRM);
        
        dsocket = new DatagramSocket();
        address = InetAddress.getByName(host);

        System.out.println("Connected.");
	System.out.println("Control-C to exit");

        receiver.start();
	Thread.sleep(1000000);

	} catch (Exception ex) {
            System.err.println("Encountered an Exception... " + ex.getMessage());
	}

    }
 
开发者ID:roberthsieh,项目名称:broadcastme,代码行数:42,代码来源:OutputProxy.java


示例3: init

import com.solacesystems.jcsmp.JCSMPSession; //导入依赖的package包/类
@PostConstruct
public void init() {
	// Connect to Solace
	trace.info("************* Init Called ************");
	trace.info(System.getenv("VCAP_SERVICES"));

	CloudFactory cloudFactory = new CloudFactory();
	Cloud cloud = cloudFactory.getCloud();
	
	SolaceMessagingInfo solaceMessagingServiceInfo =
			(SolaceMessagingInfo) cloud.getServiceInfo("solace-messaging-demo-instance");
	
	if (solaceMessagingServiceInfo == null) {
		trace.error("Did not find instance of 'solace-messaging' service");
		trace.error("************* Aborting Solace initialization!! ************");
		return;
	}
	
	trace.info("Solace client initializing and using SolaceMessagingInfo: " + solaceMessagingServiceInfo);

	final JCSMPProperties properties = new JCSMPProperties();
	properties.setProperty(JCSMPProperties.HOST, solaceMessagingServiceInfo.getSmfHost());
	properties.setProperty(JCSMPProperties.VPN_NAME, solaceMessagingServiceInfo.getMsgVpnName());
	properties.setProperty(JCSMPProperties.USERNAME, solaceMessagingServiceInfo.getClientUsername());
	properties.setProperty(JCSMPProperties.PASSWORD, solaceMessagingServiceInfo.getClientPassword());
	
	try {
		session = JCSMPFactory.onlyInstance().createSession(properties);
		session.connect();
		
		clientName = (String)session.getProperty(JCSMPProperties.CLIENT_NAME);

		final Queue queue = JCSMPFactory.onlyInstance().createQueue("Q/demo/requests");
		 
		// set queue permissions to "consume" and access-type to "exclusive"
		final EndpointProperties endpointProps = new EndpointProperties();
		endpointProps.setPermission(EndpointProperties.PERMISSION_CONSUME);
		endpointProps.setAccessType(EndpointProperties.ACCESSTYPE_NONEXCLUSIVE);
		 
		// Actually provision it, and do not fail if it already exists
		session.provision(queue, endpointProps, JCSMPSession.FLAG_IGNORE_ALREADY_EXISTS);
		
		producer = session.getMessageProducer(new PublisherEventHandler());

		final ConsumerFlowProperties flowProp = new ConsumerFlowProperties();
		flowProp.setEndpoint(queue);
		flowProp.setAckMode(JCSMPProperties.SUPPORTED_MESSAGE_ACK_CLIENT);
		
		final FlowReceiver cons = session.createFlow(new DemoMessageListener(), flowProp, endpointProps);
		cons.start();
		
		System.out.println("************* Solace initialized correctly!! ************");
		

	} catch (Exception e) {
		Trace.error("Error connecting and setting up session.", e);
	}
}
 
开发者ID:SolaceLabs,项目名称:sl-cf-solace-messaging-demo,代码行数:59,代码来源:SolaceController.java


示例4: run

import com.solacesystems.jcsmp.JCSMPSession; //导入依赖的package包/类
public void run(String... args) throws JCSMPException, InterruptedException {
    final LinkedList<MsgInfo> msgList = new LinkedList<MsgInfo>();

    System.out.println("ConfirmedPublish initializing...");
    // Create a JCSMP Session
    final JCSMPProperties properties = new JCSMPProperties();
    properties.setProperty(JCSMPProperties.HOST, args[0]);     // host:port
    properties.setProperty(JCSMPProperties.USERNAME, args[1].split("@")[0]); // client-username
    properties.setProperty(JCSMPProperties.PASSWORD, args[2]); // client-password
    properties.setProperty(JCSMPProperties.VPN_NAME,  args[1].split("@")[1]); // message-vpn
    final JCSMPSession session = JCSMPFactory.onlyInstance().createSession(properties);
    session.connect();

    String queueName = "Q/tutorial";
    final Queue queue = JCSMPFactory.onlyInstance().createQueue(queueName);

    /** Correlating event handler */
    final XMLMessageProducer prod = session.getMessageProducer(new PubCallback());

    // Publish-only session is now hooked up and running!
    System.out.printf("Connected. About to send " + count + " messages to queue '%s'...%n", queue.getName());

    for (int i = 1; i <= count; i++) {
        TextMessage msg = JCSMPFactory.onlyInstance().createMessage(TextMessage.class);
        msg.setDeliveryMode(DeliveryMode.PERSISTENT);
        String text = "Confirmed Publish Tutorial! Message ID: " + i;
        msg.setText(text);

        // The application will wait and confirm the message is published
        // successfully.
        // In this case, wrap the message in a MsgInfo instance, and
        // use it as a correlation key.
        final MsgInfo msgCorrelationInfo = new MsgInfo(i);
        msgCorrelationInfo.sessionIndependentMessage = msg;
        msgList.add(msgCorrelationInfo);

        // Set the message's correlation key. This reference
        // is used when calling back to responseReceivedEx().
        msg.setCorrelationKey(msgCorrelationInfo);

        // Send message directly to the queue
        prod.send(msg, queue);
    }
    System.out.println("Messages sent. Processing replies.");
    try {
        latch.await(); // block here until message received, and latch will flip
    } catch (InterruptedException e) {
        System.out.println("I was awoken while waiting");
    }

    // Process the replies
    while (msgList.peek() != null) {
        final MsgInfo ackedMsgInfo = msgList.poll();
        System.out.printf("Removing acknowledged message (%s) from application list.\n", ackedMsgInfo);
    }

    // Close session
    session.closeSession();
}
 
开发者ID:SolaceSamples,项目名称:solace-samples-java,代码行数:60,代码来源:ConfirmedPublish.java



注:本文中的com.solacesystems.jcsmp.JCSMPSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FlurryAdErrorType类代码示例发布时间:2022-05-22
下一篇:
Java ConfigLoader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap