How to get connection pool statistics from Teiid resource adapter? - teiid

I have resource adapter in wildfly-teiid-server with xml
<resource-adapter id="salesforcefour" statistics-enabled="true">
<module slot="main" id="org.jboss.teiid.resource-adapter.salesforce-41"/>
<connection-definitions>
<connection-definition class-name="org.teiid.resource.adapter.salesforce.SalesForceManagedConnectionFactory" jndi-name="java:/sfDS41" enabled="true" connectable="true" use-java-context="true" pool-name="sfDS41">
<config-property name="connectTimeout">30000</config-property>
<config-property name="password"></config-property>
<config-property name="URL">https://test.salesforce.com/services/Soap/u/45.0</config-property>
<config-property name="requestTimeout">120000</config-property>
<config-property name="username"></config-property>
<pool>
<min-pool-size>5</min-pool-size>
<initial-pool-size>5</initial-pool-size>
<prefill>true</prefill>
<use-strict-min>true</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
</connection-definition>
</connection-definitions>
</resource-adapter>
For checking that connection pool really get active connections I need get statistics.
I tied to execute jboss-cli.sh and commends
/subsystem=resource-adapters/resource-adapter=salesforcefour:write-attribute(name=statistics-enabled,value=true)
/subsystem=resource-adapters/statistics=statistics/connection-definitions=java\:\/sfDS41:read-resource(include-runtime=true)
But get error
Failed to get the list of the operation properties: "WFLYCTL0030: No resource definition is registered for address [
("subsystem" => "resource-adapters"),
("statistics" => "statistics"),
("connection-definitions" => "java:/sfDS41")
]"
How to check connection pool statistics or just get current active connections count?

Answer from https://github.com/teiid/teiid/pull/1335
For non-jdbc resource adapters it is specified on the pool for the given connection definition:
/subsystem=resource-adapters/resource-adapter=salesforcefour/connection-definitions=sfDS/statistics=pool:write-attribute(name=statistics-enabled, value=true)
You just need to substitute in the name of the connection definition you used - that is the logical name, which is likely not the jndi name. You can auto complete on subsystem=resource-adapters/resource-adapter=salesforcefour/connection-definitions= to see your connection definition names. You should then be able to read the pool statistics against that connection definition name.

Related

WSO2 APIM-Analytic service (version:2.6.0) is not able to send the alert emails

In order to test this function, I chosed Abnormal Request Count option, which is in Alert Management menu of Api Store, and added a restful api. Then I called this api for many times by Postman.
The carbon.log, which is in <API-M_ANALYTICS_HOME>/wso2/worker/logs, recorded the following error message:
[2020-10-19 11:03:36,094] ERROR {org.wso2.siddhi.core.stream.output.sink.Sink} - Error on 'APIM_ALERT_EMAIL_NOTIFICATION'. Dropping event at Sink 'email' at 'EmailNotificationStream' as its still trying to reconnect!, events dropped '<strong>Message:</strong>A request from a new IP (10.9.16.77) detected by user:admin#carbon.super using application:devMap owned by admin#carbon.super. <br><br> <strong>Type:</strong>UnusualIPAccess <br><br> <strong>AlertTimestamp:</strong>2020-10-19 11:03:35'
[2020-10-19 11:06:10,307] ERROR {org.wso2.siddhi.core.stream.output.sink.Sink} - Error on 'APIM_ALERT_EMAIL_NOTIFICATION'. Dropping event at Sink 'email' at 'EmailNotificationStream' as its still trying to reconnect!, events dropped '<strong>Message:</strong>Abnormal request count detected during last minute using application devMap owned by admin#carbon.super for api :全球风向查询, abnormal request count:9. <br><br> <strong>Type:</strong>AbnormalRequestsPerMin <br><br> <strong>AlertTimestamp:</strong>2020-10-19 11:06:10'
About detailed configuration, I referred the following links:
Configuring Alerts:
https://docs.wso2.com/display/AM260/Configuring+Alerts#ConfiguringAlerts-ConfiguringalertsviatheStore
Enabling Notifications:
https://docs.wso2.com/display/AM260/Enabling+Notifications
According to these documents, I did the following things:
1.Open the <API-M_ANALYTICS_HOME>/conf/worker/deployment.yaml file to configure the sender email address. The sample code is shown below:
siddhi:
extensions:
...
-
extension:
name: email
namespace: sink
properties:
username: abcd#163.com
address: abcd#163.com
password: xxxx
...
2.Go to the <API-M_ANALYTICS_HOME>/resources/apim-analytics/ directory. Copy the APIM_ALERT_EMAIL_NOTIFICATION.siddhi file and paste it in the <API-M_ANALYTICS_HOME>/wso2/worker/deployment/siddhi-files directory.
3.Set the email server configurations in the <API-M_HOME>/repository/conf/output-event-adapters.xml file under the section.
<adapterConfig type="email">
<!-- Comment mail.smtp.user and mail.smtp.password properties to support connecting SMTP servers which use trust
based authentication rather username/password authentication -->
<property key="mail.smtp.from">abcd#163.com</property>
<property key="mail.smtp.user">abcd</property>
<property key="mail.smtp.password">xxxx</property>
<property key="mail.smtp.host">smtp.163.com</property>
<property key="mail.smtp.port">25</property>
<property key="mail.smtp.starttls.enable">true</property>
<property key="mail.smtp.auth">true</property>
<!-- Thread Pool Related Properties -->
<property key="minThread">8</property>
<property key="maxThread">100</property>
<property key="keepAliveTimeInMillis">20000</property>
<property key="jobQueueSize">10000</property>
</adapterConfig>
4.Log in to the Management Console and click Main > Resource > Browse. Browse to the /_system/config/apimgt/applicationdata/tenant-conf.json file and click Edit as Text.Set the NotificationsEnabled property to true as shown below:
"NotificationsEnabled":"true",
"Notifications":[{
"Type":"new_api_version",
"Notifiers" :[{
"Class":"org.wso2.carbon.apimgt.impl.notification.NewAPIVersionEmailNotifier",
"ClaimsRetrieverImplClass":"org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever",
"Title": "Version $2 of $1 Released",
"Template": " <html> <body> <h3 style=\"color:Black;\">We’re happy to announce the arrival of the next major version $2 of $1 API which is now available in Our API Store.</h3>Click here to Visit WSO2 API Store</body></html>"
}]
}
]
I've also checked APIM_ALERT_EMAIL_NOTIFICATION.siddhi:
#App:name("APIM_ALERT_EMAIL_NOTIFICATION")
#App:description('Send email to all the subscribers of a particular alert')
#source(type="inMemory", topic="APIM_EMAIL_NOTIFICATION", #map(type='passThrough'))
define stream EmailAlertStream (
type string,
message string,
alertTimestamp string,
emails string);
#sink(type='email', content.type="text/html", #map(type ='text', #payload('<strong>Message:</strong>{{message}} <br><br> <strong>Type:</strong>{{type}} <br><br> <strong>AlertTimestamp:</strong>{{alertTimestamp}}')),subject='Alerts from WSO2 APIM Analytics',to='{{emails}}')
define stream EmailNotificationStream (
type string,
message string,
alertTimestamp string,
emails string);
from EmailAlertStream
select *
insert into EmailNotificationStream;
As you can see, there is nothing special.
Have I missed anything to do? I don't know what the problem is, please help me.
As per the exceptions you received. Looks like there are issues with connecting to the SMTP server. Can you please check the configurations and check there are any restrictions to use your email.
ex: in Gmail, you have to enable 'untrusted applications' to access Gmail.
I've found the reason of this problem.
By reading the source code (EmailSink.java), I know the information of SMTP Server should be configured in APIM_ALERT_EMAIL_NOTIFICATION.siddhi, otherwise the analytic server is going to use smtp.gmail.com by default.

mule - web service consumer (soap) always returns null

I am using the Zuora soap API. I am attempting to perform a query. I don't get any errors but the results are always null when I output the payload to log. What am I doing wrong? (the query I provide below should return 320 records, which is what I get if I execute the same query in a local non-mule test script)
This is the section of the flow.
I set the zoql query to flowVars (flowVars.query). For example : select id from Account WHERE updatedDate > '2016-06-24T23:00:00-06:00'
I use dataweave to create the xml payload (dw provided below)
I execute the query (web service consumer app xml details provided below)
DataWeave to set payload:
%dw 1.0
%output application/xml
%namespace ns0 http://api.zuora.com/
---
{
ns0#query: {
ns0#queryString: flowVars.query
}
}
Web Service Consumer app xml
<ws:consumer config-ref="ZuoraWebServiceConsumer" operation="query" doc:name="query_zuora"/>
ZuoraWebServiceConsumer config details:
<ws:consumer-config name="ZuoraWebServiceConsumer" wsdlLocation="zuora.a.49.0-sandbox.wsdl" service="ZuoraService" port="Soap" serviceAddress="https://apisandbox-api.zuora.com" doc:name="Web Service Consumer">
<ws:security>
<ws:wss-username-token username="myusername.here" password="mypassword.here" passwordType="TEXT" />
</ws:security>
</ws:consumer-config>
And the WSDL:
https://www.dropbox.com/s/fkrppvv7i5s1a4w/zuora.a.49.0-sandbox.wsdl?dl=0
After working with MuleSoft Support, it was discovered there is a bug with the Zuora connector. When Zuora returns an invalid session error, the Zuora connector is not catching it, destroying the connection from the pool, and initiating a new connection. MuleSoft has confirmed the bug.

Spring 4 REST web-services not working with security

I am using Spring 4, with Spring Security 4 to secure web-services. A normal web-service worked fine without security. My secured web-services also seemed to work great working locally and with unit testing.
We are using the SiteMinder example, which means we have authentication happenind from a remote authority. This delivers a token to the browser when we login. We pass the authentication token with a request header, and this is pulled from customerUserDetailsService. That class and methods pull the token from the header, authenticates the user against that remote authority, and we get a username. From that username, we make a DAO call to our database to get the User Details and their Roles, which in the Spring Security Context uses the roles to grant authority. This is all working fine, and we get an authenticated user and we have thier roles/grantedAuthorities.
So, as previously stated, we are now just securing web-services with spring-security.xml to secure the web-services based on the role of the user. Again, this all seemed to work fine with unit testing. We had a token for a user who did not have access to web-sites and we correctly got back a 403 error. When we used a token for a user who did have the right role, was able to execute the web-service.
Now I am trying to deploy this into a new environment, and I am not having much luck.
So, I have a spring-security.xml that looks like:
<http use-expressions="true" auto-config="false" entry-point-ref="http403EntryPoint">
<!-- Additional http configuration omitted -->
<intercept-url pattern="/records/authorizedRecords" access="hasRole('portalUser')" />
<intercept-url pattern="/records/myCode" access="hasRole('portalUser')" />
<intercept-url pattern="/users/email" access="hasRole('appAdmin')" />
<custom-filter position="PRE_AUTH_FILTER" ref="openAmFilter" />
</http>
<beans:bean id="openAmFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
<beans:property name="principalRequestHeader" value="openam_token"/>
<beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>
<beans:bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
<beans:property name="preAuthenticatedUserDetailsService">
<beans:bean id="userDetailsServiceWrapper" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
<beans:property name="userDetailsService" ref="customUserDetailsService"/>
</beans:bean>
</beans:property>
</beans:bean>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="preauthAuthProvider" />
</authentication-manager>
<beans:bean id="customUserDetailsService" class="com.agmednet.server.security.CustomUserDetailsService"></beans:bean>
<beans:bean id="http403EntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint">
When we tried access to:
<intercept-url pattern="/users/email/*" access="hasRole('appAdmin')" />
this did not seem to match:
/rest/users/email/myemail#someemail.com
so I changed it to:
<intercept-url pattern="/rest/users/email/*" access="hasRole('appAdmin')" />
And I get this from the log.
DEBUG: org.springframework.security.web.util.matcher.AntPathRequestMatcher - Checking match of request : '/rest/trials/integratedtrials'; against '/rest/users/email/*'
DEBUG: org.springframework.security.web.access.intercept.FilterSecurityInterceptor - Public object - authentication not attempted
DEBUG: org.springframework.security.web.FilterChainProxy - /rest/trials/integratedTrials reached end of additional filter chain; proceeding with original chain
DEBUG: org.springframework.security.web.access.ExceptionTranslationFilter - Chain processed normally
DEBUG: org.springframework.security.web.context.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
At this point, I know we have an authenticated user, the username, and the roles are listed right there in the logs. We seem to find a matching URL in the spring-security.xml, the URL matches, the roles match, and now I feel we should be executing the logic behind the web-service, but I get an error message:
Apache Tomcat/8.0.30 - Error report
/services/rest/users/email/myemail#someemail.com
The requested resource is not available.
I am absolutely floored here .... unsecured web-services work great. I have to be missing something? Is it with the word "rest" in the URL? Web-services have always worked when they were unsecured. I added security and add unit tests to test this all out, and now I am unsure of what happened?
The problem is that I am an idiot!!!!
In the /WEB-INF/web.xml file I had this defined:
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I suppose that is why when I call any RESTful web-services with:
/rest/users/email/myemail#someemail.com
it doesn't work.
But when I use:
/api/users/email/myemail#someemail.com
now it works.
Conclusion: I am an idiot!!!

IN clause usage in WSO2 DSS

I'm facing wso2 data service problem with simple query.
Expected query:
I want to use IN clause with multiple value. This is my sample query:
SELECT ORGANIZATION_ID, ORGANIZATION_NAME FROM ORGANIZATION WHERE ORGANIZATION_ID IN (?)
ORDER BY ORGANIZATION_NAME ASC
Getting error:
When i try web service using "1,2,3" value, i get javax.xml.stream.XMLStreamException error.
How can i write above query in WSO2 DSS?
Please advice me on that.
Thanks,
Eba
Refer the following data service query configuration which contains a sample input parameter of type "ARRAY" which you can effectively use to get your requirement fulfilled.
<query id="setSalaryForEmployeesQuery" useConfig="default">
<sql>update Employees set salary=:salary where employeeNumber in (:employeeNumbers)</sql>
<param name="salary" ordinal="1" paramType="SCALAR" sqlType="DOUBLE" type="IN"/>
<param name="employeeNumbers" ordinal="2" paramType="ARRAY" sqlType="INTEGER" type="IN"/>
</query>
There, if you refer the input mapping configuration named "employeeNumbers", it basically addresses the same requirement mentioned in your query.
To try this functionality, you can use the "tryIt" functionality provided with each data service(similar to other service types) and the data service request format corresponding to the aforementioned configuration would look like what's depicted below.
<p:setSalaryForEmployees xmlns:p="http://ws.wso2.org/dataservice/samples/rdbms_sample">
<!--Exactly 1 occurrence-->
<xs:salary xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1000</xs:salary>
<!--1 or more occurrences-->
<xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1011</xs:employeeNumbers>
<xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1022</xs:employeeNumbers>
</p:setSalaryForEmployees>
The complete data service configuration which contains the above configuration snippet can be located in the "DSS_HOME/sample/dbs/rdbms/RDBMSSample.dbs" which resides in DSS product archive.

Reply mechanism and Tx management in Oracle BPEL

I am getting request timed out exception when invoking an asynchronous BPEL service from a synchrnous BPEL service.
Am in the learning stage and created an async bpel with a wait of only 5 seconds and invoked it using a synchronous BPEL but still am getting a timedout error
The invoked async process has completed after waiting for 5 seconfs but even then the sync process is waiting for response
While invoking the the same asynchronous service using another async bpel service its working fine.
why am getting this error while a async bpel service is invoked using a sync service
I tried to change the sync process transaction property to 'requriesNew' by a wild guess
Async Process
<?xml version = "1.0" encoding = "UTF-8" ?>
<!--
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Oracle JDeveloper BPEL Designer
Created: Wed Jan 30 16:13:48 IST 2013
Author: loganvm
Type: BPEL 1.1 Process
Purpose: Asynchronous BPEL Process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-->
<process name="TestAsync"
targetNamespace="http://xmlns.oracle.com/BankInterestRate/TestAsyncproject/TestAsync"
xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:client="http://xmlns.oracle.com/BankInterestRate/TestAsyncproject/TestAsync"
xmlns:ora="http://schemas.oracle.com/xpath/extension"
xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:bpel2="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap">
<!--
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PARTNERLINKS
List of services participating in this BPEL process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-->
<partnerLinks>
<!--
The 'client' role represents the requester of this service. It is
used for callback. The location and correlation information associated
with the client role are automatically set using WS-Addressing.
-->
<partnerLink name="testasync_client" partnerLinkType="client:TestAsync" myRole="TestAsyncProvider" partnerRole="TestAsyncRequester"/>
</partnerLinks>
<!--
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
VARIABLES
List of messages and XML documents used within this BPEL process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-->
<variables>
<!-- Reference to the message passed as input during initiation -->
<variable name="inputVariable" messageType="client:TestAsyncRequestMessage"/>
<!-- Reference to the message that will be sent back to the requester during callback -->
<variable name="outputVariable" messageType="client:TestAsyncResponseMessage"/>
<variable messageType="bpelx:bindingFault" name="FaultVar"/>
<variable messageType="bpelx:remoteFault" name="FaultVar_1"/>
</variables>
<faultHandlers>
<catch faultName="bpelx:bindingFault" faultVariable="FaultVar"/>
</faultHandlers>
<!--
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ORCHESTRATION LOGIC
Set of activities coordinating the flow of messages across the
services integrated within this business process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-->
<sequence name="main">
<!-- Receive input from requestor. (Note: This maps to operation defined in TestAsync.wsdl) -->
<receive name="receiveInput" partnerLink="testasync_client" portType="client:TestAsync" operation="process" variable="inputVariable" createInstance="yes"
bpelx:conversationId="1"/>
<assign name="assign_hello">
<bpelx:append>
<bpelx:from expression="concat(bpws:getVariableData('inputVariable','payload','/client:process/client:input'),' Hello')"/>
<bpelx:to variable="outputVariable" part="payload"
query="/client:processResponse/client:result"/>
</bpelx:append>
</assign>
<wait name="Wait1" for="'PT5S'"/>
<!--
Asynchronous callback to the requester. (Note: the callback location and correlation id is transparently handled using WS-addressing.)
-->
<invoke name="callbackClient" partnerLink="testasync_client" portType="client:TestAsyncCallback" operation="processResponse" inputVariable="outputVariable"
bpelx:invokeAsDetail="no" bpelx:conversationId="1"/>
</sequence>
</process>
To debug this problem:
enabled audit, run in a development mode and then run the synchronous process from the test console. This will show you the process flow, invocations and the place where the synchronous process is waiting.
try adding any of these combinations in the transaction properties.
bpel.config.transaction=required
bpel.config.oneWayDeliveryPolicy=async.persist
If above pair is no help... try just adding below and comment out bpel.config.transaction property
bpel.config.oneWayDeliveryPolicy=async.persist