Mule ESB - SMTP Subject from a variable - java

I'm working on a flow to send an attached file to a mail.
<smtp:outbound-endpoint host="${instance.smtp.host}" port="${instance.smtp.port}" user="${instance.smtp.user}" password="${instance.smtp.password}" responseTimeout="10000" doc:name="SMTP" connector-ref="SMTP" from="${instance.smtp.account}" to="${instance.smtp.user}" subject="Transaction ID #[flowVars.transactionId]"/>
Everything is working well, I already have tested my flow and the mails are arriving to the specified mail address, however, I'm trying to modify the subject dynamically, using a value stored in a variable, and then the problem appears, seems like it's not possible to use my expression to set the subject's mail.
subject="Transaction ID #[flowVars.transactionId]"
This is the error I'm getting.
Root Exception stack trace:
[Error: unresolvable property or identifier: Transaction]
[Near : {... Transaction ID #[flowVars.tran ....}]
^
Do you have any clue about this problem or how can I fix it?
Thanks in advance.

You need to rearrange the expression so all of it is within the #[....]
subject="#['Transaction ID ' + flowVars.transactionId]"
Some fields get parsed as MEL expressions and some are more like templated strings that allow expression substitutions.
(One of Mule's annoyances)

Please debug the application and test if your flow variable for "transactionId" is being set before reaching to the SMTP message source.

Related

JMS message listener invoker failed, Cause: Identifier contains invalid JMS identifier character '-': 'x-request-id'

I'm working with JMS and queues (Azure queues) for the first time. I'm required to make a queue where Rubi server would write some data and Java would read it from queue and will do further executions.
This process is working fine locally on my machine. I've created a REST endpoint which is writing data in the queue and once data is written in the queue, the listener would take over and read the data and execute.
When we deploy it to Azure the error I can see in logs which is not letting the Queues start is
Setup of JMS message listener invoker failed for destination 'queue' - trying to recover. Cause: Identifier contains invalid JMS identifier character '-': 'x-request-id'
Zipkin is also present on the Azure server as a distributed tracing system and I guess this x-request-id is related to Zipkin which is creating the problem. I've searched Google for the issue but couldn't understand why its happening.
Following is detailed error message:
[36mc.m.s.l.NextGenRequestLoggingFilter [0;39m [2m:[0;39m
Before request [uri=/services/deal-service/api/v2/deals/ack;headers=
[x-request-id:"2d8d86d7-4fbf-9db6-8e95-28813f21a85c",
x-envoy-internal:"true", x-b3-parentspanid:"a209cdc649b0b890", content-
length:"575", x-forwarded-proto:"http", postman-token:"ad074595-
76a5-474b-9711-7e071b12b3b0", x-b3-sampled:"1", x-forwarded-
for:"10.244.2.1", accept:"*/*",
authorization: "some-token-YJc4tg--34jPRziJNSACqNQ", x-b3-
traceid:"6b40ff22781be67ba209cdc649b0b890", x-b3-
spanid:"702684ddb62cfe6b",
host:"portal-gateway.52.228.65.225.nip.io",
cache-control:"no-cache", accept-encoding:"gzip, deflate, br",
user-agent:"PostmanRuntime/7.22.0",
Content-Type:"application/xml;charset=UTF-8"]]
2020-02-18T15:19:34.197666458Z [2m2020-02-18 15:19:34.197[0;39m .
[32mDEBUG
[,6b40ff22781be67ba209cdc649b0b890,702684ddb62cfe6b,true][0;39m .
[35m9[0;39m [2m---[0;39m [2m[ XNIO-1 task-15][0;39m
Section 3.5.1 of the JMS 2 specification states this about message properties:
Property names must obey the rules for a message selector identifier. See
Section 3.8 “Message selection” for more information.
In regards to identifiers, section 3.8.1.1 states, in part:
An identifier is an unlimited-length character sequence that must begin with a Java identifier start character; all following characters must be Java identifier part characters. An identifier start character is any character for which the method Character.isJavaIdentifierStart returns true. This includes '_' and '$'. An identifier part character is any character for which the method Character.isJavaIdentifierPart returns true.
If you pass the character - into either Character.isJavaIdentifierStart or Character.isJavaIdentifierPart the return value is false. In other words, the - character in the name of a message property violates the JMS specification and therefore will cause an error.
From the error message its obvious that you are using qpid JMS client for communication through queues.
qpid client won’t allow any keys which violates java variable naming convention e.g. you won’t be able to send x-request-id in a queue’s header
which qpid jms client is consuming as it’ll throw error.
You need to take care of istio/zipkin to not to add certain headers (id you don’t need them actually) with the queue when its trying to communicate on azure bus.
So you have to disable the istio/zipkin libraries to intercept the request for queues so that request to/from queue can be made without headers. This will fix the issue.
Details of error (Java stack trace) would be really useful here.
By error message I assume, you are using qpid JMS client, that is performing check of message properties' names. These names can contain only characters, that are valid Java identifier characters.
In string 'queue-name' there is a '-' character, that is not Java identifier. To fix, you need to change 'queue-name' into something with valid characters, for example 'queue_name' (with underscore), or 'queueName' (camel case).

GCM Topic messaging error

I want to let my application to register for topic messaging, but each time I try to call Topic registration it is returning the error below
java.lang.IllegalArgumentException: Invalid topic name:
Using the method bellow
GcmPubSub.getInstance(context).subscribe(regToken, "/topics/testTopic", null);
I am using the tutorial on this link https://developers.google.com/cloud-messaging/topic-messaging. I will greatly appreciate your help on this error.
Please try this with the sample app. "/topics/testTopic" should be fine. As mentioned in the documentation, any topic name matching this regex should be fine: /topics/[a-zA-Z0-9-_.~%]+
For anyone running into this error: double check that you conform to the specification on the topic name: /topics/[a-zA-Z0-9-_.~%]+.
The original question actually does conform to the spec and I have no answer for why the error occurs. However another way to trigger the error is not conforming to the spec. In my case I mistakenly assumed path separator characters are allowed and used a topic like /topics/users/123 to mimic my REST API. The last slash is not allowed.

The security group 'gettingstartedgroup' does not exist

I am trying to learn Amazon AWS. I ran their tutorial package-"GettingStartedApp.java" after setting my access id and access key in the property file. But I see this exception.
Caught Exception: The security group 'gettingstartedgroup' does not exist
Reponse Status Code: 400
Error Code: InvalidGroup.NotFound
How should I correct this?
You are probably trying to use the string "gettingstartedgroup" as a security group.
If you just created your EC2 AWS instance, then you either add a security group with that name or use the default one.
For the latter, just change from gettingstartedgroup to default.
At first, please execute CreateSecurityGroupApp.java and then GettingStartedGroup will be creataed in Oregon region.

boolean is set to false by default when passed in SOAP request

Situation : I am coding a web service in which soap client sends the request to web service which will update the database.
Suppose, there is a table project_team_members and service will be updating info of individual team member.
There is a column in table IS_TEAM_LEADER which can have '0' or '1' as value.
Problem: When updating TL info, if I am not sending IS_TL field from SOUP UI (A SOAP Client), it is automatically received as 'false' by default in java code.
How can i know if user is sending it or not, i mean i am not able to send null in case of boolean data-type from SOAP client
Revisiting my own question after so many years.
Giving response to myself at 2012 :)
One option can be, to send whatever is there in the database as it is, back to the server. But for this prior read call is necessary.
Another option is given by Jesse's(comment under question) as an answer/solution
If there is any field, e.g. Foo, there is often an associated
IsFooSpecified property to determine if the value was set or not. If
there an IsIsTeamLeadSpecified property you can access?
PS: There wasn't any field as suggested by Jesse but this can help someone else.

Cannot get Axis example to run

I am trying to run the Axis "getting started" example code from here:
http://ws.apache.org/axis/java/user-guide.html#BasicsGettingStarted
Other than adding a missing quote on line 15 it is the same code with some added logging. I get this error:
Transport is org.apache.axis.transport.http.HTTPTransport#4c6aacbf
Set target endpoint address
Set operation name
Enter: Call::invoke(ns, meth, args)
operation=null
Failed to set EntityResolver to null on DocumentBuilder
java.lang.NullPointerException
at weblogic.xml.jaxp.ChainingEntityResolver.popEntityResolver(ChainingEntityResolver.java:75)
at weblogic.xml.jaxp.RegistryDocumentBuilder.setEntityResolver(RegistryDocumentBuilder.java:179)
Any ideas? I saw that there was a similar question but without an answer. I am using Axis 1.3 and Weblogic 9.2.3.
Thanks
The first thing that strikes me is that the URL:
http://ws.apache.org:5049/axis/services/echo
does not seem to be available. Can you try another?

Categories