I try to write sample producer & consumer with SpringIntegration and RabbitMQ.
Here My rabbit.xml config file:
<rabbit:connection-factory id="connectionFactory" />
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:queue name="queue.request" />
<rabbit:queue name="queue.response" />
<rabbit:direct-exchange name="exchange.main">
<rabbit:bindings>
<rabbit:binding queue="queue.request" key="binding.queue.request"/>
<rabbit:binding queue="queue.response" key="binding.queue.response" />
</rabbit:bindings>
</rabbit:direct-exchange>
and
producer.xml file:
<context:annotation-config />
<import resource="classpath:META-INF/zcore/integration/rabbit.xml" />
<int:channel id="request" />
<int:channel id="response" />
<int-amqp:outbound-channel-adapter channel="request" amqp-template="amqpTemplate"
exchange-name="exchange.main" routing-key="binding.queue.request"
<int-amqp:inbound-channel-adapter channel="response" queue-names="queue.response"
connection-factory="connectionFactory" />
<int:gateway id="baseGateway" service-interface="org.zcoreframework.integration.gateway.BaseGateway"
default-request-channel="request" default-reply-channel="response" />
and
consumer.xml file:
<import resource="classpath:META-INF/zcore/integration/rabbit.xml" />
<context:annotation-config />
<context:component-scan base-package="org.zcoreframework" />
<int:channel id="request" />
<int:channel id="response" />
<int-amqp:inbound-channel-adapter channel="request" queue-names="queue.request"
connection-factory="connectionFactory" />
<int-amqp:outbound-channel-adapter channel="response" amqp-template="amqpTemplate"
exchange-name="exchange.main" routing-key="binding.queue.response" />
<int:service-activator ref="messageConsumer" method="onMessage" input-channel="request"
output-channel="response" />
and I wrote this snipped code for send message and get the response:
#Autowired
BaseGateway baseGateway;
#Test
public void testHelloWorld() {
CallMethodMessage callMethodMessage = new CallMethodMessage();
callMethodMessage.setMethod("test");
callMethodMessage.setArgs(null);
System.out.print("send & receive ");
ReturnModel returnModel = this.baseGateway.SendWait(callMethodMessage);
//this.baseGateway.FireForget(callMethodMessage);
}
and this is my interface
public interface BaseGateway {
#Gateway
public void FireForget(CallMethodMessage method);
#Gateway
public ReturnModel SendWait(CallMethodMessage method);
}
OK now I run consumer separately then for the first one I run producer with method FireForget and everything is OK, cosumer gets it and prints a message but when I run with SendWait method the cosumer gets it but not return anything and the producer waits to get the response, How can I handle this problem?
There is no correlation for the reply
<int-amqp:outbound-channel-adapter channel="request" amqp-template="amqpTemplate"
exchange-name="exchange.main" routing-key="binding.queue.request"
<int-amqp:inbound-channel-adapter channel="response" queue-names="queue.response"
connection-factory="connectionFactory" />
Use an outbound-gateway instead; you can configure it with a Rabbit Template with a <reply-listener/> as discussed in the Spring AMQP documentation.
And use an inbound gateway on the consumer side.
Related
I m implementing mule ESB 3.9 to consume messages from active mq.
I have around 15 domain components to which it actually orchestrates to reach the final destination
I have configured a connection pool for jms and am using numberofconsumers as 32 and maximum thread in reciever as 500.
But what I see is until 4 messages per second the requests sent by jmeter is fine. But if I increase to 5 msgs per second then I find the request sent by jms averages to around 3 msgs per second slowly..
Any thought on how to configure the number of consumers and reciever thread ?
My target is 10 messages per second and also all my 15 components takes only 30 milli seconds each at max to process .so processing time by those components is good...yet I see the total throughput is around 3 seconds at times and mostly its because messages are not being picked immediately.
Please suggest
Activemq xml
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" >
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="10000"/>
</pendingMessageLimitStrategy>
<slowConsumerStrategy>
<abortSlowConsumerStrategy/>
</slowConsumerStrategy>
</policyEntry>
<!--Mahesh added start-->
<policyEntry queue=">" >
<slowConsumerStrategy>
<abortSlowConsumerStrategy/>
</slowConsumerStrategy>
</policyEntry>
<!--Mahesh added end-->
</policyEntries>
</policyMap>
</destinationPolicy>
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="90" />
</memoryUsage>
<storeUsage>
<storeUsage limit="5 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="5 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
Other information on Mule ESB
I am using a prefetch of 1 message
No of consumers are 32 and receiver threads are 500
mule-config ---->
<spring:beans>
<context:component-scan base-package="com.test.esb.orm.db" />
<spring:import resource="classpath*:applicationContext.xml" />
<spring:import resource="classpath*:test-orm-beans.xml" />
<spring:import resource="mule-domain-spring.xml"/>
</spring:beans>
<db:generic-config name="Generic_Database_Configuration"
dataSource-ref="testDataSource"
doc:name="Generic Database Configuration"/>
<db:generic-config name="Generic_TrackTraceDatabase_Configuration"
dataSource-ref="testTrackTraceDataSource"
doc:name="Generic Database Configuration for Track Trace"/>
<!-- ********************* ESB Gateway Configurations ******************************** -->
<http:listener-config name="test-Shared-http-listener" host="${domain.gateway.host}" port="${domain.gateway.port}" doc:name="HTTP Listener connector for ESB Gateway (From ui)">
<http:worker-threading-profile maxThreadsActive="64"
poolExhaustedAction="WAIT"
threadWaitTimeout="30000" />
</http:listener-config>
<jms:activemq-connector name="com.test.esb.trans.jmsConnector"
username="${domain.amq.user.id}" password="${domain.amq.user.password}"
connectionFactory-ref="pooledConnectionFactory"
numberOfConsumers="16" acknowledgementMode="AUTO_ACKNOWLEDGE"
validateConnections="true"
persistentDelivery="true"
doc:name="AMQ Connector For Domain Routing Services"
specification="1.1">
<receiver-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<dispatcher-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<reconnect count="15" frequency="5000" blocking="true"/>
</jms:activemq-connector>
<jms:activemq-connector name="com.test.esb.domain.jmsConnector"
username="${domain.amq.user.id}" password="${domain.amq.user.password}"
connectionFactory-ref="pooledConnectionFactory"
numberOfConsumers="16" acknowledgementMode="AUTO_ACKNOWLEDGE"
validateConnections="true"
persistentDelivery="false"
doc:name="AMQ Connector For Domain Routing Services"
specification="1.1">
<receiver-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<dispatcher-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<reconnect count="15" frequency="5000" blocking="true"/>
</jms:activemq-connector>
<jms:activemq-connector name="com.test.esb.domain.orchestrator.jmsConnector"
username="${domain.amq.user.id}" password="${domain.amq.user.password}"
connectionFactory-ref="pooledConnectionFactory"
numberOfConsumers="16" acknowledgementMode="AUTO_ACKNOWLEDGE"
validateConnections="true"
persistentDelivery="true"
doc:name="AMQ Connector For Domain Routing Services"
specification="1.1">
<receiver-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<dispatcher-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<reconnect count="15" frequency="5000" blocking="true"/>
</jms:activemq-connector>
<jms:activemq-connector name="com.test.esb.interface2.jmsConnector"
username="${domain.amq.user.id}" password="${domain.amq.user.password}"
connectionFactory-ref="pooledConnectionFactory"
validateConnections="true"
numberOfConcurrentTransactedReceivers="16"
persistentDelivery="false"
doc:name="AMQ Connector for interface2 Interface"
specification="1.1">
<receiver-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT" threadWaitTimeout="30000"/>
<dispatcher-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<reconnect count="15" frequency="5000" blocking="true"/>
</jms:activemq-connector>
<jms:activemq-connector name="com.test.esb.destination.router.jmsConnector"
username="${domain.amq.user.id}" password="${domain.amq.user.password}"
connectionFactory-ref="pooledConnectionFactory"
validateConnections="true"
numberOfConcurrentTransactedReceivers="8"
persistentDelivery="false"
doc:name="AMQ Connector for DestinationRouter"
specification="1.1">
<receiver-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<dispatcher-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT"/>
<reconnect count="15" frequency="5000" blocking="true"/>
</jms:activemq-connector>
<jms:activemq-connector name="com.test.esb.dlq.jmsConnector"
username="${domain.amq.user.id}" password="${domain.amq.user.password}"
connectionFactory-ref="pooledConnectionFactory"
validateConnections="true"
numberOfConcurrentTransactedReceivers="16"
persistentDelivery="false"
doc:name="AMQ Connector for Dead Letter Queue"
specification="1.1">
<receiver-threading-profile maxThreadsActive="500" poolExhaustedAction="WAIT" threadWaitTimeout="30000"/>
<reconnect count="15" frequency="5000" blocking="true"/>
</jms:activemq-connector>
mule-spring config---->
<spring:bean id="domainRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<spring:property name="maximumRedeliveries" value="5" />
<spring:property name="initialRedeliveryDelay" value="500" />
<spring:property name="maximumRedeliveryDelay" value="10000" />
<spring:property name="useExponentialBackOff" value="false" />
<spring:property name="backOffMultiplier" value="3" />
</spring:bean>
<!-- ActiveMQ Connection factory -->
<spring:bean id="domainConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" lazy-init="true">
<spring:property name="brokerURL"
value="tcp://192.0.0.0:61616?jms.prefetchPolicy.all=1" />
<spring:property name="redeliveryPolicy" ref="domainRedeliveryPolicy" />
</spring:bean>
<!-- amqExceptionConnectionFactory Connection factory -->
<spring:bean id="amqExceptionConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" lazy-init="true">
<spring:property name="brokerURL"
value="failover:(${domain.amq.failover.url}?jms.prefetchPolicy.all=50)" />
<spring:property name="redeliveryPolicy" ref="domainRedeliveryPolicy" />
</spring:bean>
<spring:bean id="pooledConnectionFactory" class="org.apache.activemq.jms.pool.PooledConnectionFactory" >
<spring:property name="connectionFactory" ref="domainConnectionFactory"/>
<spring:property name="maxConnections" value="10000" />
<spring:property name="maximumActiveSessionPerConnection" value="10000" />
</spring:bean>
<spring:bean id="trackTraceRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<spring:property name="maximumRedeliveries" value="5" />
<spring:property name="initialRedeliveryDelay" value="500" />
<spring:property name="maximumRedeliveryDelay" value="10000" />
<spring:property name="useExponentialBackOff" value="false" />
<spring:property name="backOffMultiplier" value="3" />
</spring:bean>
<spring:bean id="trackTraceConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" lazy-init="true">
<spring:property name="brokerURL"
value="failover:(${domain.amq.failover.url})" />
<!-- value="tcp://${domain.amq.host}:${domain.amq.port}" /> -->
<spring:property name="redeliveryPolicy" ref="trackTraceRedeliveryPolicy" />
</spring:bean>
<spring:bean id="interface2ConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" lazy-init="true">
<spring:property name="brokerURL"
value="tcp://192.0.0.0:61616?jms.prefetchPolicy.all=1" />
<!-- value="tcp://${domain.amq.host}:${domain.amq.port}" /> -->
<spring:property name="redeliveryPolicy" ref="interface2RedeliveryPolicy" />
</spring:bean>
<spring:bean id="interface2RedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<spring:property name="maximumRedeliveries" value="5" />
<spring:property name="initialRedeliveryDelay" value="500" />
<spring:property name="maximumRedeliveryDelay" value="10000" />
<spring:property name="useExponentialBackOff" value="false" />
<spring:property name="backOffMultiplier" value="3" />
</spring:bean>
<!-- ********************* Destination Router Configurations ******************************** -->
<!-- ActiveMQ Connection factory for destination Router -->
<spring:bean id="destinationRouterConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" lazy-init="true">
<spring:property name="brokerURL"
value="tcp://192.0.0.0:61616?jms.prefetchPolicy.all=1" />
<!-- value="tcp://${domain.amq.host}:${domain.amq.port}" /> -->
<spring:property name="redeliveryPolicy"
ref="destinationRouterRedeliveryPolicy" />
</spring:bean>
<spring:bean id="destinationRouterRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<spring:property name="maximumRedeliveries" value="5" />
<spring:property name="initialRedeliveryDelay" value="500" />
<spring:property name="maximumRedeliveryDelay" value="10000" />
<spring:property name="useExponentialBackOff" value="false" />
<spring:property name="backOffMultiplier" value="3" />
</spring:bean>
<!-- ********************* Dead Letter Queue (DLQ) Configurations ******************************** -->
<!-- ActiveMQ Connection factory for Dead Letter Queue -->
<spring:bean id="dlqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" lazy-init="true">
<spring:property name="brokerURL"
value="failover:(${domain.amq.failover.url})" />
<spring:property name="redeliveryPolicy" ref="dlqRedeliveryPolicy" />
</spring:bean>
<spring:bean id="dlqRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<spring:property name="maximumRedeliveries" value="5" />
<spring:property name="initialRedeliveryDelay" value="500" />
<spring:property name="maximumRedeliveryDelay" value="10000" />
<spring:property name="useExponentialBackOff" value="false" />
<spring:property name="backOffMultiplier" value="3" />
</spring:bean>
numberOfConsumers is the atribute that determines the number of client threads if the endpoing is using transactions. If the endpoint is in a transaction then you need to use numberOfConcurrentTransactedReceivers instead.
You should really remove the <dispatcher-threading-profile> and <receiver-threading-profile> configurations. 500 threads per JMS configuration is a lot for your system, it is a lot of resources if they are created, and will not help for this use case at all. You should set these values only because of some real reason.
Try to capture a thread dump when the processing is slow to analyze what are the threads doing. That should point to the root cause.
Reference: https://help.mulesoft.com/s/article/JMS-Usage-of-numberOfConsumers-and-numberOfConcurrentTransactedReceivers
Good day, I'm trying to log in with google and my config.xml file I have it this way
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.terabit.facilpark" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<hook src="hooks/hookers.js" type="before_prepare" />
<hook src="hooks/beforedep.js" type="before_deploy" />
<name>FacilPark</name>
<description>
</description>
<preference name="AndroidLaunchMode" value="singleTask" />
<universal-links>
<host name="facilpark19.page.link" scheme="https" />
<host name="facilpark-bdfd1.firebaseapp.com" scheme="https">
<path url="/__/auth/callback" />
</host>
</universal-links>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Terabit
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<allow-navigation href="*" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-buildinfo" spec="^2.0.2" />
<plugin name="cordova-plugin-browsertab" spec="^0.2.0" />
<plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
<plugin name="cordova-plugin-customurlscheme" spec="^4.3.0">
<variable name="URL_SCHEME" value="com.terabit.facilpark" />
</plugin>
<plugin name="cordova-universal-links-plugin" spec="~1.2.1" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.1" />
<plugin name="cordova.plugins.diagnostic" spec="^4.0.10" />
<plugin name="cordova-open-native-settings" spec="^1.5.2" />
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<engine name="browser" spec="^5.0.2" />
<engine name="android" spec="^7.0.0" />
</widget>
and the motod to initiate session in the following way:
loginGoogle(){
console.log("LOGIN GOOGLE");
const provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(provider).then(function() {
return firebase.auth().getRedirectResult();
}).then(result =>{
// This gives you a Google Access Token. You can use it to access the Google API.
console.log("AUTENTICACION POR GOOGLE EXITOSA")
this.completarInicio(user);
//this.$router.replace('home');
console.log(result);
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
},
The problem I have is to log in from the application, after having selected the google account and enter password I get the following message:
How can I correct the above mentioned, thank you very much.
Go to your Firebase Console, and on the Project Overview page there's a very small button called Add App. Select the OS and then enter your app bundle id.
can you inject a value from the config params file in to the splitter group attribute? if so, what is the proper way of doing it? thanks!
I've tried,
<split streaming="true" >
<tokenize token="\n" group="{{noOfLines}}" />
<log message="Split Group Body: ${body}"/>
<to uri="bean:extractHeader" />
<to id="acceptedFileType" ref="pConsumer" />
</split>
<split streaming="true" >
<tokenize token="\n" group={{noOfLines}} />
<log message="Split Group Body: ${body}"/>
<to uri="bean:extractHeader" />
<to id="acceptedFileType" ref="pConsumer" />
</split>
what am I doing wrong?
ERROR: 'Open quote is expected for attribute "group" associated with an element type "tokenize".
<tokenize token="\n" group="<simple>${properties:noOfLines:500}</simple>" />
ERROR: 'The value of attribute "group" associated with an element type "tokenize" must not contain the '<' character.'
<tokenize token="\n" group="${properties:noOfLines:500}" />
Caused by: org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '${properties:noOfLines:500}' is not a valid value for 'integer'.
my quest for info and answers didn't go deep enough. I found this was already encounted and answered by Claus Ibsen. Please see if you run in to this need.
Validation error with integer property (camel)
http://camel.apache.org/using-propertyplaceholder.html
under section "Using Property Placeholders for Any Kind of Attribute in the XML DSL"
here is what I did following these instructions.
added property prefix namespace
xmlns:prop="http://camel.apache.org/schema/placeholder"
then modified the tokenize attribute
<tokenize token="\n" prop:group="noOfLines" />
I'm using the property placeholder
<cm:property-placeholder persistent-id="com.digital.passthru.core" />
this works like a charm. thank you Claus.
this is what worked for me.
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:prop="http://camel.apache.org/schema/placeholder"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder persistent-id="com.ge.digital.passthru.core" />
<bean id="deadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
<property name="deadLetterUri" value="${deadLetterQueue}"/>
<property name="redeliveryPolicy" ref="redeliveryPolicyConfig"/>
<property name="useOriginalMessage" value="true" />
</bean>
<bean id="redeliveryPolicyConfig" class="org.apache.camel.processor.RedeliveryPolicy">
<property name="maximumRedeliveries" value="3"/>
<property name="redeliveryDelay" value="5000" />
</bean>
...
<camelContext
id="com.ge.digital.passthru.coreCamelContext"
trace="true"
xmlns="http://camel.apache.org/schema/blueprint"
allowUseOriginalMessage="false"
streamCache="true"
errorHandlerRef="deadLetterErrorHandler" >
...
<route
id="core.predix.accept.file.type.route"
autoStartup="true" >
<from uri="{{fileEntranceEndpoint}}" />
<convertBodyTo type="java.lang.String" />
<split streaming="true" strategyRef="csvAggregationStrategy">
<tokenize token="\n" />
<process ref="toCsvFormat" /> <!-- passthru only we do not allow embedded commas in numeric data -->
</split>
<log message="CSV body: ${body}" loggingLevel="INFO"/>
<choice>
<when>
<simple>${header.CamelFileName} regex '^.*\.(csv|CSV|txt|gpg)$'</simple>
<log message="${file:name} accepted for processing..." />
<choice>
<when>
<simple>${header.CamelFileName} regex '^.*\.(CSV|txt|gpg)$'</simple>
<setHeader headerName="CamelFileName">
<!-- <simple>${file:name.noext}.csv</simple> --> <!-- file:name.noext.single -->
<simple>${file:name.noext.single}.csv</simple>
</setHeader>
<log message="${file:name} changed file name." />
</when>
</choice>
<split streaming="true" >
<tokenize token="\n" prop:group="noOfLines" />
<log message="Split Group Body: ${body}"/>
<to uri="bean:extractHeader" />
<to id="acceptedFileType" ref="predixConsumer" />
</split>
<to uri="bean:extractHeader?method=cleanHeader"/>
</when>
<otherwise>
<log message="${file:name} is an unknown file type, sending to unhandled repo." loggingLevel="INFO" />
<to uri="{{unhandledArchive}}" />
</otherwise>
</choice>
</route>
...
and noOfLines is a property
now there is an order to all this as I found out while doing this also.
please go to the link below for the Camel ordering of components in XML DSL
Camel DataFormat Jackson using blueprint XML DSL throws context exception
I'm trying to send log messages to my gmail account but it keeps not working. I've tried changing ports and changing threshold value but it's not working. When I try writing logs in file everything is ok, so I think the problem is in log4net.config file.
My log4net configuration file contains:
<log4net>
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="mymail#gmail.com" />
<from value="mysendermail#gmail.com" />
<subject value="Crash log" />
<smtpHost value="smtp.gmail.com" />
<authentication value="Basic" />
<port value="465" />
<username value="myusername" />
<password value="mypass" />
<bufferSize value="1" />
<EnableSsl value="true"/>
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="DEBUG"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d{hh:mm:ss} %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="SmtpAppender"/>
</root>
</log4net>
In my Startup.cs file I have:
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
And my example code is:
public class HomeController : Controller
{
private static readonly ILog log = LogManager.GetLogger(typeof(HomeController));
public HomeController()
{
}
public IActionResult Index()
{
return View();
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
ViewData["Title"] = "title";
log.Warn("test test", new NullReferenceException("missing"));
log.Debug("test test", new NullReferenceException("missing"));
log.Error("test test", new NullReferenceException("missing"));
log.Fatal("test test", new NullReferenceException("missing"));
return View();
}
}
Am I making something wrong. I tried everything
log4net's SmtpAppender is not supported in .net core yet.
Supported frameworks: https://logging.apache.org/log4net/release/framework-support.html
Have you tested the following port:
Gmail SMTP port (TLS): 587
Gmail SMTP port (SSL): 465 <- your current setting
what-are-the-gmail-smtp-settings
I had everything working fine the other day, but now when I go to login I get a 403 error saying the requested page is forbidden. The user is still successfully logged in, i.e. I can go back and gain access to the pages that are secure. There are not errors in the console.
login.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Login Page</title>
<link href="${pageContext.request.contextPath}/resources/css/main.css"
rel="stylesheet" type="text/css">
</head>
<body onload='document.f.j_username.focus();'>
<h3>Login with Username and Password</h3>
<c:if test="${param.error != null}">
<p class="error">Login failed. Check user name and password.</p>
</c:if>
<form name='f'
action='${pageContext.request.contextPath}/j_spring_security_check'
method='POST'>
<table class="formtable">
<tr>
<td class="title">User:</td>
<td><input class="control" type='text' name='j_username' value=''></td>
</tr>
<tr>
<td class="title">Password:</td>
<td><input class="control" type='password' name='j_password' /></td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit"
value="Login" /></td>
</tr>
</table>
</form>
<p>Create a new account. </p>
</body>
</html>
security-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service
data-source-ref="dataSource" />
</security:authentication-provider>
</security:authentication-manager>
<security:http use-expressions="true">
<security:intercept-url pattern="/adminPortal"
access="hasRole('admin')" />
<security:intercept-url pattern="/addDrug"
access="hasRole('admin')" />
<security:intercept-url pattern="/drugAdded"
access="hasRole('admin')" />
<security:intercept-url pattern="/addingDrug"
access="hasRole('admin')" />
<security:intercept-url pattern="/drugList"
access="hasRole('admin')" />
<security:intercept-url pattern="/userList"
access="hasRole('admin')" />
<security:intercept-url pattern="/doctorPortal"
access="hasRole('doctor')" />
<security:intercept-url pattern="/pharmacistPortal"
access="hasRole('pharmacist')" />
<security:intercept-url pattern="/customerPortal"
access="hasRole('customer')" />
<security:intercept-url pattern="/" access="permitAll" />
<security:intercept-url pattern="/resources/**"
access="permitAll" />
<security:intercept-url pattern="/login"
access="permitAll" />
<security:intercept-url pattern="/newAccount"
access="permitAll" />
<security:intercept-url pattern="/accountCreated"
access="permitAll" />
<security:intercept-url pattern="/createAccount"
access="permitAll" />
<security:intercept-url pattern="/logout"
access="permitAll" />
<security:intercept-url pattern="/**" access="denyAll" />
<security:form-login login-page="/login"
authentication-failure-url="/login?error=true" />
<security:logout logout-success-url="/logout" />
</security:http>
Login Controller
package com.pharmacy.management.system.controller;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.pharmacy.management.system.dao.User;
import com.pharmacy.management.system.service.UserService;
#Controller
public class LoginController {
private UserService userService;
#Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
#RequestMapping("/login")
public String showLogin() {
return "login";
}
#RequestMapping("/logout")
public String showLogout() {
return "logout";
}
#RequestMapping("/newAccount")
public String newAccount(Model model) {
model.addAttribute("user", new User());
return "newAccount";
}
#RequestMapping("/accountCreated")
public String accountCreated(Model model) {
model.addAttribute("user", new User());
return "accountCreated";
}
#RequestMapping(value = "/createAccount", method = RequestMethod.POST)
public String createAccount(#Valid User user, BindingResult result) {
if (result.hasErrors()) {
return "newAccount";
}
user.setAuthority("doctor");
user.setEnabled(true);
if (userService.exists(user.getUsername())) {
result.rejectValue("username", "DuplicateKey.user.username");
return "newAccount";
}
try {
userService.create(user);
} catch (DataAccessException e) {
result.rejectValue("username", "DuplicateKey.user.username");
return "newAccount";
}
return "accountCreated";
}
}
<security:intercept-url pattern="/**" access="denyAll" />
you write at last change sequence of it. put first of all other definition.
Try do it as my configuration. The order url intercept order is very important:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- HTTP security configurations -->
<http auto-config="true" use-expressions="true">
<form-login login-processing-url="/resources/j_spring_security_check"
login-page="/login" authentication-failure-url="/login?login_error=t" />
<logout logout-url="/resources/j_spring_security_logout" />
<!-- Configure these elements to secure URIs in your application -->
<intercept-url pattern="/choices/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/member/**" access="isAuthenticated()" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/login/**" access="permitAll" />
<intercept-url pattern="/home/**" access="permitAll" />
<intercept-url pattern="/password/reset" access="hasRole('ROLE_ANONYMOUS')" />
<intercept-url pattern="/account/create" access="hasRole('ROLE_ANONYMOUS')" />
<intercept-url pattern="/account/activate" access="hasRole('ROLE_ANONYMOUS')" />
<intercept-url pattern="/password/change" access="isAuthenticated()" />
<intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/client/**" access="hasRole('ROLE_CLIENT')" />
<intercept-url pattern="/**" access="permitAll" />
</http>
<!-- Configure Authentication mechanism -->
<authentication-manager alias="authenticationManager">
<authentication-provider ref="customAuthenticationProvider" />
</authentication-manager>
<beans:bean id="passwordEncoder"
class="org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder">
<beans:constructor-arg value="SHA-256" />
</beans:bean>
</beans:beans>