//public Action<string> TestAction { get; set; }
        public object handle(String consumerTag, PFMqMessage message)
        {
            String strMessage = message.getMessage();

            //if (TestAction != null) { TestAction(strMessage); }
            return("接收到信息:" + strMessage);
        }
Esempio n. 2
0
        public void BuildPFEmailMqConsumer(PFMqHelper.PFConsumerResponseTask pfDeliverCallback)
        {
            PFMqConfig mqConfig = pfDeliverCallback.GetMqConfig(_mqConfig);
            //string producerEmailTitle = "PFEmailMq_producer_" + "会员资料表";//中文有问题--benjamin todo
            //string producerEmailTitle = "PFEmailMq_producer_" + "hyzl";
            //消费方(使用系统邮箱)
            string result = "";
            //bool success = false;
            var consumerTask = new PFListenEmailTask("PFEmailMqConsumerListener_" + mqConfig.getTopic(),
                                                     new PFEmailManager(PFDataHelper.SysEmailHostName, PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd),
                                                     email =>
            {
                //result = "{success:true}";
                PFMqMessage pfMessage = new PFMqMessage(email);
                var r = pfDeliverCallback.handle(mqConfig.getTag(), pfMessage);
                if (r != null)
                {
                    var UserEmailUserName = PFDataHelper.SysEmailUserName;
                    ////消费方回复邮件(暂不回复--benjamin)
                    PFDataHelper.SendEmail(PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd, PFDataHelper.SysEmailHostName,
                                           new string[] { UserEmailUserName }, "PFEmailMq_consumer_Response_" + mqConfig.getTopic() + email.Body,
                                           JsonConvert.SerializeObject(r));
                }
            },
                                                     (email//, task
                                                     ) =>
            {
                //消费方监听生产方邮件
                //return email.Subject != null && email.Subject.IndexOf("TestForceUpdateHyzl_") == 0;//这里不要用>-1,否则可能把自动回复的邮件也当作是了
                return(email.Subject == "PFEmailMq_product_" + mqConfig.getTopic());
            });

            consumerTask.Start();
        }
Esempio n. 3
0
        //	public  void BuildRabbitMqConsumer(PFMqHelper.PFConsumerTask pfDeliverCallback) {

        //		try {
        //	        //rabbitmq
        //		    PFMqConfig mqConfig=pfDeliverCallback.GetMqConfig(_mqConfig);

        //	        com.rabbitmq.client.ConnectionFactory factory = new com.rabbitmq.client.ConnectionFactory();
        //		    factory.setHost(mqConfig.getHost());
        //		    Connection connection;
        //			connection = factory.newConnection();
        //		    Channel channel = connection.createChannel();
        //		    String QUEUE_NAME=mqConfig.getQueueName();
        //		    channel.queueDeclare(QUEUE_NAME, false, false, false, null);
        //		    System.out.println("\r\n  [*][rabbitMq] queueName:"+QUEUE_NAME+"\r\n    Waiting for messages.\r\n");

        //		    DeliverCallback deliverCallback = (consumerTag, delivery) -> {
        //		        PFMqMessage pfMessage=new PFMqMessage(delivery);
        //		        String logMsg="\r\n  [x][rabbitMq] queueName:"+QUEUE_NAME+"\r\n    "+pfDeliverCallback.getClass().getSimpleName()+" Received '" + pfMessage.getMessage() + "' \r\n";
        //		        WriteLog(logMsg);
        //		        pfDeliverCallback.handle(consumerTag,pfMessage);
        //		    };
        //		    channel.basicConsume(QUEUE_NAME, true, deliverCallback, consumerTag -> { });
        //		} catch (IOException | TimeoutException e) {
        //			// TODO Auto-generated catch block
        //			e.printStackTrace();
        //		}
        //	}
        //	public  void BuildRocketMqConsumer(PFConsumerTask pfDeliverCallback) {

        //        try {
        //		    PFMqConfig mqConfig=pfDeliverCallback.GetMqConfig(_mqConfig);
        //			//org.apache.rocketmq.client.consumer.DefaultMQPushConsumer consumer = new org.apache.rocketmq.client.consumer.DefaultMQPushConsumer("test-group");
        //	//        consumer.setNamesrvAddr("localhost:9876");
        //	//        consumer.setInstanceName("rmq-instance");
        //	//        consumer.subscribe("log-topic", "user-tag");
        //			org.apache.rocketmq.client.consumer.DefaultMQPushConsumer consumer = new org.apache.rocketmq.client.consumer.DefaultMQPushConsumer(mqConfig.getGroupId());
        //	        consumer.setNamesrvAddr(mqConfig.getNameSrvAddr());

        //	        if(!PFDataHelper.StringIsNullOrWhiteSpace(_mqConfig.getInstanceName())) {
        //	            consumer.setInstanceName(_mqConfig.getInstanceName());
        //	        }

        //	        consumer.subscribe(mqConfig.getTopic(),mqConfig.getTag());

        //	        consumer.registerMessageListener(new org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently() {
        //				@Override
        //				public org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {

        //		          for (MessageExt msg : msgs) {
        //				        PFMqMessage pfMessage=new PFMqMessage(msg);
        //				        String logMsg="\r\n [x][rocketMq] topic:"+mqConfig.getTopic()+" tag:"+mqConfig.getTag()+"\r\n    "+pfDeliverCallback.getClass().getSimpleName()+" Received '" + pfMessage.getMessage() + "' \r\n ";
        //				        WriteLog(logMsg);
        //						pfDeliverCallback.handle( mqConfig.getTag(),pfMessage);
        //		          }
        //		          return org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
        //				}
        //	        });
        ////	        consumer.registerMessageListener(new org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly() {
        ////
        ////				@Override
        ////				public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
        ////			          for (MessageExt msg : msgs) {
        ////			              System.out.println("消费者消费数据:"+new String(msg.getBody()));
        ////			          }
        ////			          return org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus.SUCCESS;
        ////				}
        ////	        });
        //			consumer.start();
        //			System.out.println("\r\n [*][rocketMq] topic:"+mqConfig.getTopic()+" tag:"+mqConfig.getTag()+"\r\n    Waiting for messages.\r\n");
        //		} catch (MQClientException e) {
        //			// TODO Auto-generated catch block
        //			e.printStackTrace();
        //		}

        //	}
        //	public  void BuildAliMqConsumer(PFConsumerTask pfDeliverCallback) {
        //		//参考:D:\eclipse_workspace\IpaasTest\src\com\mq\simple\ConsumerTest.java
        //        Properties properties = GetAliMqProperties();

        //	    PFMqConfig mqConfig=pfDeliverCallback.GetMqConfig(_mqConfig);

        //        Consumer consumer = ONSFactory.createConsumer(properties);

        //		consumer.subscribe(mqConfig.getTopic(), mqConfig.getTag(), new MessageListener() {
        //		    public Action consume(Message message, ConsumeContext context) {
        //		        PFMqMessage pfMessage=new PFMqMessage(message);
        //		        String logMsg="\r\n [x][aliMq] topic:"+mqConfig.getTopic()+" tag:"+mqConfig.getTag()+"\r\n    "+pfDeliverCallback.getClass().getSimpleName()+" Received '" + pfMessage.getMessage() + "' \r\n ";
        //		        WriteLog(logMsg);
        //				pfDeliverCallback.handle( mqConfig.getTag(),pfMessage);
        //		        return Action.CommitMessage;
        //		    }
        //		});
        //        consumer.start();
        //	    System.out.println("\r\n [*][aliMq] topic:"+mqConfig.getTopic()+" tag:"+mqConfig.getTag()+"\r\n    Waiting for messages.\r\n");
        //	}

        //public void BuildPFEmailMqConsumer(PFMqHelper.PFConsumerTask pfDeliverCallback)
        //{
        //    PFMqConfig mqConfig = pfDeliverCallback.GetMqConfig(_mqConfig);
        //    //string producerEmailTitle = "PFEmailMq_producer_" + "会员资料表";
        //    //string producerEmailTitle = "PFEmailMq_producer_" + "hyzl";
        //    //消费方(使用系统邮箱)
        //    string result = "";
        //    //bool success = false;
        //    var consumerTask = new PFListenEmailTask("PFEmailMqConsumerListener_" + mqConfig.getTopic(),
        //    new PFEmailManager(PFDataHelper.SysEmailHostName, PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd),
        //    email =>
        //    {
        //        //result = "{success:true}";
        //        PFMqMessage pfMessage = new PFMqMessage(email);
        //        var r = pfDeliverCallback.handle(mqConfig.getTag(), pfMessage);
        //        if (r != null)
        //        {
        //            var UserEmailUserName = PFDataHelper.SysEmailUserName;
        //            ////消费方回复邮件(暂不回复--benjamin)
        //            PFDataHelper.SendEmail(PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd, PFDataHelper.SysEmailHostName,
        //                new string[] { UserEmailUserName }, "PFEmailMq_consumer_Response_" + email.Subject + email.Body,
        //               JsonConvert.SerializeObject(r));
        //        }
        //    },
        //    (email//, task
        //    ) =>
        //    {
        //        //消费方监听生产方邮件
        //        //return email.Subject != null && email.Subject.IndexOf("TestForceUpdateHyzl_") == 0;//这里不要用>-1,否则可能把自动回复的邮件也当作是了
        //        return email.Subject == mqConfig.getTopic();
        //    });
        //    consumerTask.Start();

        //}
        public void BuildPFEmailMqConsumer(PFMqHelper.PFConsumerTask pfDeliverCallback)
        {
            PFMqConfig mqConfig = pfDeliverCallback.GetMqConfig(_mqConfig);
            //string producerEmailTitle = "PFEmailMq_producer_" + "会员资料表";
            //string producerEmailTitle = "PFEmailMq_producer_" + "hyzl";
            //消费方(使用系统邮箱)
            string result = "";
            //bool success = false;
            var consumerTask = new PFListenEmailTask("PFEmailMqConsumerListener_" + mqConfig.getTopic(),
                                                     new PFEmailManager(PFDataHelper.SysEmailHostName, PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd),
                                                     email =>
            {
                //result = "{success:true}";
                PFMqMessage pfMessage = new PFMqMessage(email);
                pfDeliverCallback.handle(mqConfig.getTag(), pfMessage);
            },
                                                     (email//, task
                                                     ) =>
            {
                //消费方监听生产方邮件
                //return email.Subject != null && email.Subject.IndexOf("TestForceUpdateHyzl_") == 0;//这里不要用>-1,否则可能把自动回复的邮件也当作是了
                return(email.Subject == "PFEmailMq_product_" + mqConfig.getTopic());
            });

            consumerTask.Start();
        }
Esempio n. 4
0
        public object handle(String consumerTag, PFMqMessage message)
        {
            var lastCMonth = ProjDataHelper.GetLastCMonthByDate(DateTime.Now);

            var p = JsonConvert.DeserializeObject <PagingParameters>(message.ToString());
            var backupDatabase = PFDataHelper.ObjectToString(p["backupDatabase"]) ?? "";
            var service        = new DbReportService(lastCMonth);
            var list           = service.GetCompareCntList(backupDatabase, false);

            return(list);
        }