Spring Boot Cloud + RabbitMQ - spring-boot

I'm new to Spring, Spring Boot and RabbitMQ. However I'm an okay programmer/problem solver.
Recently I started go through this book Learning Spring Boot 2.0 - Second Edition, code for this can be found here https://github.com/learning-spring-boot/learning-spring-boot-2nd-edition-code.
I think that things were moving along okay for me...a few hiccups here and there, but whatever as long as I was able to progress and learn I figured I was doing fine.
I'm just over half way through this book and then the author starts talking about Spring Cloud Streams and RabbitMQ.
I'm now working with the code found here https://github.com/learning-spring-boot/learning-spring-boot-2nd-edition-code/tree/master/6/part3.
My code doesn't produce an error, but it doesn't produce the expected results either. When I run the application the image comments do not seem to be saved or shown. I get a log message like this
o.s.a.r.c.CachingConnectionFactory : Created new connection:
SpringAMQP#2920fd66:0/SimpleConnection#59ae4da8
[delegate=amqp://guest#127.0.0.1:5672/, localPort= 57615]
when I submit the data.
However the book states that I should get getting messages like the following:
o.s.integration.channel.DirectChannel : preSent on channel input,
message: GenericMessage [payload=Comment(id=null,imageId=book.jpg)]
Looking at what I should be getting it appears as thought the problem may be related to channels. Maybe the issue is not channels, maybe it's something else.
How should I go about finding the exact cause of this of the problem?

I am not familiar with Greg's book but I just loaded that app into eclipse and it seems to work fine for me. After uploading an image it shows up in the list.
I then comment on the image and I see...
2018-01-19 00:04:41.046 DEBUG 16612 --- [ctor-http-nio-3] o.s.integration.channel.DirectChannel : preSend on channel 'output', message: GenericMessage [payload=com.greglturnquist.learningspringboot.comments.Comment#4d4f990f, headers={id=0651f9b9-e38b-1557-67dd-bc19acae8af1, timestamp=1516338281044}]
...
2018-01-19 00:07:35.570 DEBUG 17539 --- [g-spring-boot-1] o.s.integration.channel.DirectChannel : preSend on channel 'input', message: GenericMessage [payload=byte[64], headers={amqp_receivedDeliveryMode=PERSISTENT, amqp_receivedRoutingKey=learning-spring-boot-comments, amqp_receivedExchange=learning-spring-boot-comments, amqp_deliveryTag=1, amqp_consumerQueue=learning-spring-boot-comments.learning-spring-boot, amqp_redelivered=false, id=43094b53-d9b5-115e-db44-dcef73a0a9c4, amqp_consumerTag=amq.ctag-MGTGY6EuPidJy3BH7_j2zw, contentType=application/json, timestamp=1516338455570}]
But I do see
2018-01-19 00:07:54.291 ERROR 17539 --- [ctor-http-nio-3] o.s.w.s.h.ResponseStatusExceptionHandler : Response status 405 with reason "Request method 'GET' not supported"
I am not sure if you are supposed to see comments that were posted.
How should I go about finding the exact cause of this of the problem?
First step would be to enable DEBUG logging for the root logger (or all of org.springframework).
You might want to reach out to Greg on his web site.

Related

GKE: Classify log messages based on tag in message payload

I have a third-party go based app that is writing logs to stderr. Even though the log message is written as an INFO message stackdriver classifies it as ERROR because the log message is written to stderr (which seems to be default for golang logger).
Below is an example of an INFO message, but logged as ERROR
textPayload: "2022-04-05T16:41:38.369Z INFO controller.CertificateRequest CertificateRequest is Ready, ignoring. {"certificaterequest": "elasticsearch/es-http-tls-trs4t", "cr": {"namespace": "elasticsearch", "name": "es-http-tls-trs4t"}} "
Is it possible reclassify log messages based on payload tags?
I would like to classify above message as an Info rather than error so my logging alerts doesn't go crazy
Here is an interesting link:
https://huynvk.dev/blog/4-tips-for-logging-on-gcp-using-golang-and-logrus
You should use logrus and hooks.
They work the same way as aspect-oriented programming in java.
Anyway logrus is in maintenance status on github.
Otherwise you could refer to Zap or Apex (logrus design based).
https://github.com/uber-go/zap
https://github.com/apex/log

Why when I return back from login to I get an ERROR with the sample app?

This is in regards to the sample: msal-web-sample-0.1.0
I am using tomcat 9 and maven to build and run the msal-web-sample code. It is building fine and running, loading spring, etc. I am able to go out and get a username and passowrd login. However, when it tries to return back to my system (https://localhost:8443/msal4jsample/secure/aad) it just has a bit "ERROR PAGE!" heading with Home Page link going back to the main tomcat page.
In the tomcat runtime it has:
2021-06-29 15:28:06.108 ERROR 6360 --- [io-8443-exec-10] o.s.b.w.servlet.support.ErrorPageFilter : Cannot forward to error page for request [/secure/aad] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
Of course, that doesn't apply to my setup.
I see the get in the logs returning back OK and don't see any errors on startup. I am at a loss as to where to go from here. Any thoughts?
Also, is there a non-spring implementation that can be used with java but still using MSAL?
Thanks
Alan
Please share additional information about the error. Do you have trouble regrading AAD? Check your environmental settings (Tomcat) if this isn't the case.

How to debug HyperLedger Composer Transaction code in Playground

I am using a local install of Playground on MacOS.
I was successful to create my business network, add my model file and logic to this network and create assets and participants instances.
So now I am ready to submit my first transaction, but I get an error message in the popup window as a result to my request. The message per se is not the problem (it's about some Undefined asset), my problem is I want to debug this transaction code by producing some execution traces, using old-school printf or log message.
I tried to insert console.log(message) instructions in my transaction code but eventually I was not able to retrieve those logs traces (eg. using a command like docker logs -f composer).
Is there another way to produce logs traces? Or did I miss a config setting to defilter logs in docker logs?
Any help greatly appreciated!
Olivier.
On console logging (and seeing them in the browser Developer console), see this Stack Overflow here (hyperledger composer playground) Can you see results of console.log('something') in browser? (it also has a link to more info there
See here https://hyperledger.github.io/composer/latest/problems/diagnostics.html for more on logging / where to find debug logs.
As for setting checkpoint/breakpoints: These are set by the Editor tooling 🙂 In H/Composer, you can just use the embedded connector (eg such as TP functions) to try out / step through each breakpoint - for more info on VSCode -> https://code.visualstudio.com/docs/editor/debugging and Atom -> How do I set a breakpoint inside of atom's package? and I posted the link to diagnostics/logging above.
One quick way I used to insert breakpoints with debug messages, is to throw an exception using throw new Error(...) in the transaction method.
This shows up in the playground interface as well.

Sending file using Spring Batch sftp

I'm trying to send a file with sftp using Spring Batch.
I find a great example/tutorial on this site https://blog.codecentric.de/en/2011/09/send-data-secure-with-sftp-and-spring-batch/ which I followed, though I am getting the "Could not send file per SFTP: ..." caught exception in the example in the link above in the SftpTasklet class. I believe my problem is that the int-sftp:outbound-channel-adapter in my application context is never getting called. The id associated with it sftpOutboundAdapter not referenced anywhere else on the page and I do not see how it gets called. I have found similar tutorials on other sites where it is also never explicitly called.
Basically, my question comes down to: how does the spring batch int-sftp:outbound-channel-adapter get called?
Thanks in advance
The tasklet sends a message (with a File payload) to outputChannel (sftpChannel.send(message);) which, in turn sends it to the outbound adapter.
Turn on DEBUG logging for org.springframework.integration to see the messasge flow.

What does "Visualforce Remoting: Context incomplete" mean?

When using javascript remoting in a VisualForce page, I get a warning in my javascript console, "Visualforce Remoting: Context incomplete".
What does it mean, and what are the implications?
This message means that Visualforce remoting internals were not added to the remoting request.
Are you still seeing this Javascript console message? If you were seeing this message and your remoting transactions were working as expected, it's likely you were seeing an innocuous bug that has been fixed. If you're seeing this warning and your transaction is failing, please post to the Visualforce message boards giving details (https://bitly.com/). Thanks.

Resources