How to write Apple push notification using Spring AMQP? - spring

I am new to push notification. I would like to write a code using Spring AMQP which will send notification message to APN. I have .p12, certification and .pem files with me. Can anybody help me in writing the code using Spring AMQP which will send notification message.
Thanks in advance.

Spring AMQP is for sending messages to an AMQP broker, which in the case of spring is only RabbitMQ at this time. If you just have to use spring-amqp then you will need to create a producer using AmqpTemplate.convertAndSend. Then you will need a consumer that pulls messages off of the queue. See SimpleMessageListenerContainer and MessageListener for the consumer. Your consumer would contain the Push.alert("Hello World") code. Of course, the "Hello World" string would be replaced with whatever payload you are pushing to APNS.

Related

Spring Cloud Stream RabbitMQ wait for publisher confirms

I am using Spring Cloud Stream with the RabbitMQ binder. I use the StreamBridge to send messages to a destination. I want to send a message with StreamBridge and after that synchronously wait for the publisher confirm (to make sure the message was received by the broker). Is that possible using Spring Cloud Stream? I have found the RabbitTemplate's waitForConfirms method and i have publisherConfirmType: simple and publisherReturns: true set in my configuration. But i don't know how to access the method with the RabbitTemplate since i don't use it because i'm using the StreamBridge. If i Autowire a RabbitTemplate and call waitForConfirms after my StreamBridge send call, it waits forever (nothing happens). I'm looking for an option like with the Kafka binder. There you can set the Producer to "sync" and "requiredAcks" to 1 to wait for publisher acks.
Thanks for any help!

Spring web services, JMS transport and replay-to

I need to send a soap message to a queue and wait for the response into another.
The correlationId in the second one (the response queue) is the message Id in the first the message send to the request queue.
I'd like to use spring-ws but I am out of ideas. Could you please give me some advice or small example?
You can use spring integration like this example https://github.com/snicoll/scratches/blob/master/jms-request-reply/src/main/java/net/nicoll/scratch/spring/boot/jms/sync/JmsRequestReply.java
Or spring jms to do request-reply http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jms.html

How to get properly all queue messages from RabbitMQ in Spring?

I am using Spring, Spring-Websocket, STOMP for my application, and RabbitMQ as broker. I need to log all messages going through RabbitMQ to Postgresql tables.
I know that I can write #MessageMapping in Spring and log there, but my problem is that some clients talk to RabbitMQ directly through MQTT protocol, and Spring does not support it yet (https://jira.spring.io/browse/SPR-12581). Moreover browser clients talk through Spring to RabbitMQ using STOMP protocol.
RabbitMQ allows to track all messages using Firehose tracer. How to properly listen to amq.rabbitmq.trace topic from Spring? Or do I need to write separate Java app as consumer?
The Spring AMQP is for you!
You bind some custom queue to to that amq.rabbitmq.trace with appropriate pattern (e.g. publish.#) and configure SimpleMessageListenerContainer to receive messages from that queue.
It can be done even with pretty simple config: #EnableRabbit and #RabbitListener on some POJO method. Anyway the Binding #Bean must be there to attache your queue to that exchange.

How to receive message published on a topic using mqtt protocol in spring:jms application?

I am new to activemq.
I have a publisher which publish a message to a topic using mqtt protocol. And now I want to write a subscriber using Spring + JMS which will listen for the message on that topic.
I have following questions:
1) Can I have a same topic if I write the subscriber using tcp protocol.I mean to say, publisher will use MQTT to publish on a topic and subscriber will listen on that topic using TCP broker URL.
2) If above is not possible then how can I write a subscriber using spring + jms that will listen and receive the messages published on the topic using mqtt ?
Thank you in advance.
Did you even try? Yes, it works pretty much as you expect it to. MQTT msgs gets converted to JMS if you try read it with JMS (OpenWire).
From web site:
Message transformations
MQTT messages are transformed into an JMS
ByteMessage. Conversely, the body of any JMS Message is converted to a
byte buffer to be the payload of an MQTT message.

Spring JMS consumer pull

I need to implemt a pulling consumer.
Most of the examples I see are the producer pushing a message to the consumer; Assuming consumer is always up.
I want the producer to push messages to a queue and the consumer to consume those messages on its own schedule.
My consumer has a off hours calender and cannot process requests during off hours.
How would I configure that in spring.
TIA
Raghu
Use message driven POJOs and JMS.
The onMessage is a server push, The message is processed as soon as it is delivered to the client. I want the client to decide when it wants to pull the message and process it.

Resources