Grails RabbitMQ ImmediateAcknowledgeAmqpException - grails

i am trying to use the RabbitMQ plugin and whatever i do i am getting
a org.springframework.amqp.ImmediateAcknowledgeAmqpException:
Recovered
message forces ack (if ack mode requires it):...
I am sending AMQP messages using a pure Spring app using the AMQP
template and trying to handle the messages in a Grails 2.0.3 app. Is
there something that i am missing?
What can i do to get rid of this errors?
Kind Regards,
Marco

I had a similar problem. But then I realised I named my handleMessage method incorrectly. My listener class (I'm only learning!) now looks like this, and doesn't show the ImmediateAcknowledgeAmqpException.
class ListenerService {
static rabbitQueue = 'sub'
def handleMessage(message) {
println "Message received"
}
}

Related

analyzer_plugin generates Legacy protocol of Dart analyzer server instead of LSP

I try to write some custom lint rules. To achieve this, I used the analyzer_plugin package and I set up my project as it should be. Here is a simplified excerpt of the main class :
class LintAnalyzerPlugin extends ServerPlugin {
#override
Future<void> analyzeFile({required AnalysisContext analysisContext, required String path}) async {
channel.sendNotification(
AnalysisErrorsParams(path, [getAnalysisError(path)]).toNotification(),
);
}
}
channel.sendNotification is called but no message is displayed into VS Code Problems panel.
After some investigation, I found out that the JSON generated for the sent notification use Dart server Legacy protocol. But the Dart analyzer server run by Dart Code extension wait for LSP (Microsoft Language Server Protocol).
Fortunately the extension offers a setting to start the server with the Legacy protocol:
"dart.useLegacyAnalyzerProtocol": true
And now the VS Code Problems panel populates sent notifications.
Unfortunately Dart Code extension advises to use LSP because the Legacy protocol will eventually be removed some day.
Is it possible to generate LSP? Or did I miss something?
If anyone has any suggestions, I'm all ears.

Is there a method in quickfix for returning execution report acknowledgement message?

I have initiator and acceptor applications in Java. I'm using FIX 4.2 protocol.
I'm sending Execution Reports via acceptor and getting them with initiator. There's no problem in here. What I need is, return an execution report acknowledgement message(type: BN) for the acceptor. In FIX 4.2 standarts there are no BN messages. I will probably add those fields to datadictionary myself.
I checked user manual of quickfix. There are some example methods for sending messages.
void sendOrderCancelRequest() throws SessionNotFound
{
quickfix.fix41.OrderCancelRequest message = new quickfix.fix41.OrderCancelRequest(
new OrigClOrdID("123"),
new ClOrdID("321"),
new Symbol("LNUX"),
new Side(Side.BUY));
message.set(new Text("Cancel My Order!"));
Session.sendToTarget(message, "TW", "TARGET");
}
Should i write a method like above and call it inside of onMessage method? How can I response these messages?
QF does not automatically do this for you.
You will need to implement your own logic to create the ack message and send it.
And yes, you are correct that you will need to add BN and its fields to your DataDictionary. I would then recommend that you re-generate the QF/j source and rebuild the library so that you can have proper BN message/field classes. (The QF/j documentation should be able to guide you with this.)

useOriginalMessage() and multiple 'from' nodes

I'm using the Grails routing plugin which allows defining Camel routes with a Groovy DSL syntax very similar to the Java DLS syntax.
Suppose I have the following RouteBuilder:
class MyRoute extends RouteBuilder {
from('activemq:route1')
.to('someProcessor1')
.to('direct:route2')
from('direct:route2')
.to('someProcessor2')
onException(Throwable.class).useOriginalMessage().handled(true)
.to('activemq:route.failed')
}
If I have a message that starts at activemq:route1, then moves through direct:route2 but fails in the someProcessor2, then I end up with the message as it started at activemq:route1 in my activemq:route.failed queue... but that's not what I want. If I have a failure in someProcessor2, I want the message as it started at direct:route2 (and likewise, if I have a failure in someProcessor1, I want the activemq:route1 message in my failed queue).
Is there any Apache Camel feature that allows me to "reset" the original message at the beginning of a RouteDefintion (i.e. from(<uri>))?
use something besides direct: to join your routes (seda, vm, activemq) and it will behave as you suggested...otherwise, you can also explicitly preserve the relevant state of the message in a header and restore it in the onException clause, etc.

Using HttpPostRequestDecoder with Netty 3.x

I'm attempting to use HttpPostRequestDecoder from Netty Extension 1.1.9 with Netty 3.3.1. I get class cast issues, however, when trying to get from the built-in Netty HttpRequest to what is used in the org.jboss.netty.handler.codec.http2 package.
What is the correct way to go about this?
org.jboss.netty.handler.codec.http.DefaultHttpRequest request;
HttpPostRequestDecoder decoder = new HttpPostRequestDecoder((org.jboss.netty.handler.codec.http.HttpRequest) request);
I never used the netty extensions but from a quick look at the source it looks like you need to be sure to only use the http codec stuff which is shipped with it. From your description it seems like you try to mix the http codec stuff that comes with netty and the one that comes with netty extension.
Have you tried to use the HttpPostRequestDecoder from the master branch?
https://github.com/netty/netty/tree/master/codec-http/src/main/java/io/netty/handler/codec/http
It seems to be working for me. See https://github.com/mashupbots/socko/tree/master/socko-webserver/src/main/java/org/mashupbots/socko/postdecoder
You just have to get all the relevant files into your source directory and change the namespace.
I ended up writing a small converter between the http.DefaultHttpRequest and http2.DefaultHttpRequest implementations:
org.jboss.netty.handler.codec.http2.DefaultHttpRequest convertedRequest = new org.jboss.netty.handler.codec.http2.DefaultHttpRequest(HttpVersion.HTTP_1_0, org.jboss.netty.handler.codec.http2.HttpMethod.POST, request.getUri());
convertedRequest.setContent(request.getContent());
convertedRequest.setChunked(request.isChunked());
// convert the headers
for (Entry<String, String> entry : request.getHeaders()) {
convertedRequest.setHeader(entry.getKey(), entry.getValue());
}

Symfony mailer: Swift_TransportException between message sending

On a current project which I'm currently working, i have a symfony task that runs some mass data insertion to database and runs it for at least half an hour.
When the task starts a mail notification is sent correctly, the problem is that at the of the task execution we can't send another mail to notify about the end of processing.
The mailer factory is currently configured with the spool delivery strategy but, in this specific situation, we desire to fire a notification immediately, using the sendNextImmediately() method.
I'm are getting the exception:
[Swift_TransportException]
Expected response code 250 but got code "451", with message "451 4.4.2 Timeout - closing connection. 74sm1186065wem.17
"
and the flowing error on php log file:
Warning: fwrite(): SSL: Broken pipe in /var/www/project/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php on line 209
Can anyone give some help?
Is there any way that i can perhaps refresh symfony mailer to establish a new connection?
Doing a Symfony2 project, I ran across this failure too. We were using a permanently running php script, which produced the error.
We figured out that following code does the job:
private function sendEmailMessage($renderedTemplate, $subject, $toEmail)
{
$mailer = $this->getContainer()->get('mailer');
/* #var $mailer \Swift_Mailer */
if(!$mailer->getTransport()->isStarted()){
$mailer->getTransport()->start();
}
$sendException = null;
/* #var $message \Swift_Message */
$message = \Swift_Message::newInstance()
->setSubject($subject)
->setFrom($this->getContainer()->getParameter('email_from'))
->setTo($toEmail)
->setBody($renderedTemplate);
$mailer->send($message);
$mailer->getTransport()->stop();
//throw $sendException;
}
For Symfony1 Users
My guess was that the connection was being hold for too long (with no activity at all), causing an ssl connection timeout.
For now, the problem can be solved by stopping the Swift_Transport instance and starting it again explicitly, just before sending the second message.
Here is the code:
$this->getMailer()->getRealtimeTransport()->stop();
$this->getMailer()->getRealtimeTransport()->start();
$this->getMailer()->sendNextImmediately()->send($message);
I had exactly the same problem and above solutions were very helpful, but there is one thing I had to do differently: order.
$this->getMailer()->sendNextImmediately()->send($message);
$this->getMailer()->getRealtimeTransport()->stop();
It didn't worked for me if I tried to stop Transport before sending message (connection timeout was already hanging). Also You don't need to run getRealtimeTransport()->start() - it will be started automatically.

Resources