Launching EMECA rules - moqui

The messages are being successfully polled from the server. I somehow cannot manage to have the EMECA rules process the incoming messages. Is there a special way I need to configure the EMECA rule? This is what I have:
<emecas xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/email-eca-2.0.xsd">
<emeca rule-name="processMail">
<condition>
<expression>true</expression>
</condition>
<actions>
<service-call name="org.moqui.impl.EmailServices.save#EcaEmailMessage" in-map="context"/>
</actions>
</emeca>
I can see the message being polled from the server, but no rule is fired. What am I missing?

Looks like I found the answer. The file with EMECA rule had a misspelled extension.

Related

How should I set up logger for Splunk in PingFederate?

I wish to set up PingFederate to log to Splunk.
Ping describes it nicely here https://ping.force.com/Support/Configuring-PingFederate-with-Splunk but the referenced sections to be uncommented can't be found in my PF instance -- it may have been removed before my time as part of a clean-up.
What should the contents of the log4j2.xml be?
I'm using PingFederate 8.4.1.
Some additional information on configuring PingFederate's log4j2.xml is available here: https://support.pingidentity.com/s/document-item?bundleId=pingfederate-93&topicId=qst1564002981075.html
If you do not have a SecurityAudit2Splunk appender defined in your log4j2.xml, it should look something like:
<RollingFile name="SecurityAudit2Splunk" fileName="${sys:pf.log.dir}/splunk-audit.log"
filePattern="${sys:pf.log.dir}/splunk-audit.%d{yyyy-MM-dd}.log"
ignoreExceptions="false">
<PatternLayout>
<pattern>%d trackingid="%X{trackingid}" event=%X{event} subject="%X{subject}" ip=%X{ip} app=%X{app} connectionid=%X{connectionid} protocol=%X{protocol} pfhost=%X{host} role=%X{role} status=%X{status} adapterid=%X{adapterid} description="%X{description}" responsetime=%X{responsetime} %n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
If you want to see an original log4j2.xml configuration file, you can always download PingFederate again to compare: https://www.pingidentity.com/en/resources/downloads/pingfederate.html
Also note that there is a PingFederate App for Splunk that can be a useful starting point for reporting: https://splunkbase.splunk.com/app/976/

FreeSWITCH dialplan to check if enduser is registered for WebRTC to SIP

I am trying to use FreesSWITCH with the Mizu WebRTC to SIP client.
If the called user is registered to FreesSWITCH than the call should be routed to the user. Otherwise the call should be routed to outbound SIP server.
The problem is that I am unable to find out from the FreesSWITCH dialplan if user is currently registered or not. I have the following in the default dialplan:
<!-- If the user doesn't exist, forward to outbound SIP -->
<extension name="check_user">
<condition field="${user_exists(id ${destination_number} $${domain})}" expression="false">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
<!-- If the user is registered, forward the call to them -->
<extension name="check_user_registered">
<condition field="${sofia_contact(profile/${destination_number}#$${domain})}" expression="(.+)">
<action application="bridge" data="$1" />
</condition>
</extension>
<!-- Otherwise forward to outbound SIP -->
<extension name="outbound">
<condition field="destination_number" expression="^.*$">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
However the "check_user_registered" rule seems to be passed even if the user is not actually registered from the Webphone, so the FreesSWITCH will go to send the call to the user, but then finds out that it is not registered and the call fails. (I think that WebRTC doesn't matter here, this would be the same for SIP to SIP calls).This is the relevant log:
Dialplan: sofia/internal/2233#81.12.74.77 Regex (PASS) [check_user_registered] ${sofia_contact(profile/${destination_number}#rtc.mizu-voip.com)}(error/user_not_registered) =~ /(.+)/ break=on-false
Dialplan: sofia/internal/2233#81.12.74.77 Action bridge(error/user_not_registered)
Freeswitch hangup with 480 Temporarily Unavailable / USER_NOT_REGISTERED
Do you know any reliable way to query from FreesSWITCH dialplan the user registered status?
Use sofia_contact to know whether the called person is registered or not.
For example:
sofia_contact 1001 return this to me
sofia/internal/sip:1001#myip_address:52573;rinstance=a1b0a9cfddc6a8c3;transport=TCP
sofia_contact 1002
error/user_not_registered
Another option is to store the registered user into database and using odbc query fetch the result and compare.(That will be a brilliant idea)
sofia_contact returns the string error/user_not_registered if the user is not registered. And in your condition, you check the returned value against .+ regular expression. Of course the error string would match too.
You need a condition which matches on ^error, and then define the action and anti-action.

WSO2 ESB: Proxy Service - how to use faultsequence

I wish all my Proxy Services to log a standard ERROR when the endpoint publishes a soapfault. Setting faultSequence to a valid logging sequence doesn't seem to be doing anything. I know the endpoint is publishing fault responses & the faultlogger sequence is a simply FULL log.
<SOAP-ENV:Fault...> </SOAP-ENV:Fault>
<proxy ... >
<target faultSequence="faultlogger" endpoint="conf:/myService>
...
</target>
</proxy>
How does faultSequence work?
I also tried to use a out, filter + log but wasn't sure what the xpath expression I should use to filter for faults.
faultSequence is executed when there is a technical error (in your xpath for exemple, or can't connect to an address configured in an endpoint)
A SOAPFault is not a technical problem and the out sequence is executed : you can verify response message to find potentials soap faults.
An other solution is to set the property named FORCE_ERROR_ON_SOAP_FAULT :
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>

NLog smtp failover

i have NLog configured to log error to mail target using corporate smtp server.
<target name="email" xsi:type="Mail"
from="aaa#aaa.cz"
to="bbb#bbb.cz"
subject="KIT - ${logger}"
body="${message} ${exception:format=tostring}"
smtpServer="ccc.ddd.cz"
smtpPort="25"
smtpUserName="abc"
smtpPassword="abc" />
Everything works fine untill smtp server is down. I would like to somehow configure to use secondary smtp server when primary smtp server is not available - kind of SMTP failover.
Any ideas how to configure it in NLog? Is it possible to achieve this with NLog?
From the NLog FallbackGroup documentation on GitHub:
<targets>
<target xsi:type="FallbackGroup" name="String" returnToFirstOnSuccess="Boolean">
<target xsi:type="wrappedTargetType" ... />
<target xsi:type="wrappedTargetType" ... />
...
<target xsi:type="wrappedTargetType" ... />
</target>
</targets>
List your targets in the order you wish NLog to attempt to use them. Don't forget to set the name="String" (in your case "email") and the returnToFirstOnSuccess="Boolean", usually "true" but maybe not for you, depending on why you had to failover/fallback. If it is usually just a transient problem, switching back to the primary makes sense. If it is usually because the primary server goes down for extended periods, you may want to set it to false so that a successful log using the secondary server doesn't make NLog switch back to the primary each time since it will just end up doing the fallback again.

NLog in WCF Service

Can I use NLog in a WCF Service? I am trying to but cannot get it to work.
First I set up a simple configuration in a Windows Forms application to check that I was setting up correctly and this wrote the log file fine (I am writing to a network location using name and not IP address).
I then did exactly the same thing in the WCF Service. It did not work.
To check permissions I then added some code to use a TextWriter.
TextWriter tw = new StreamWriter(fileName);
tw.WriteLine(DateTime.Now);
tw.Close();
This worked OK so I know I can write to the location.
Check that your NLog.config file is in the same directory as your .svc file and NOT the Bin directory.
If you've just added the config file to the WCF project, then published it you will probably find your config file has been copied to the bin directory which is why NLog can't find it. Move it to up a level then restart the website hosting the service (to make sure the change is picked up).
This had me stumped for a while this morning!
Put your NLog config in the web.config file. Like so:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
. . . (lots of web stuff)
<nlog>
<targets>
<target name="file" xsi:type="File" fileName="${basedir}/logs/nlog.log"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
</configuration>
See my comment to your original question for how to turn on NLog's internal logging.
To turn on NLog's internal logging, modify the top of you NLog config to look like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.mono2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="nlog_log.log"
>
The key parts are internalLogLevel and internalLogFile.
You can also set internalLogToConsole to true or false to direct the internal logging to the console.
There is another setting, throwExceptions, that tells NLog whether or not to throw exceptions. Ordinarily, this is set to false once logging is successfully configured and working. You can set it to true to help determine if your problem is due to an NLog error.
So, if you had all of those options enabled, the top of your NLog configuration might look like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.mono2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="nlog_log.log"
internalLogToConsole="true"
throwExceptions="true"
>
My first guess is that NLog is not finding the config information. Are you using an external config file (NLog.config) or "inline" configuration (in your app.config or web.config)? In your project, is(are) your config file(s) marked (in Properties) as Copy Always?