[akka-user][deprecated] Exception Handling in Drools Rule Condition

2020-03-05 Thread Bishnu Shankar Pandey
Hi All,

How can we do rule wise exception handling in the drools rule condition?  
My scenario is how to handle scenarios when the schema of an event changes.

For example, let's say Initially  I have an event that has 5 members namely 
name,num1,num2,num3,num4. I started creating rules for the event and the 
rule engine is running for some time. After that let's assume there is a 
scenario in which one of the class members (say num4) is removed from the 
event because of some reason. Now what I can do now is to change the Event 
class, but all the rules associated with that member will give me 
exceptions. The exceptions will also affect other rules which can run with 
the current data. Is there any way to handle exception in rule condition 
for specific rule and restrict it to disturb the independent rules.


Regards,

Bishnu Shankar Pandey

-- 
*
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*
>>>>>>>>>> 
>>>>>>>>>>  Read the docs: http://akka.io/docs/
>>>>>>>>>>  Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/akka-user/2abd7fa1-e455-4d0c-afe0-fcf9544c8332%40googlegroups.com.


Re: [akka-user][deprecated] How can i create an akka stream from a java Native Queue?

2019-11-07 Thread Bishnu Shankar Pandey
I saw the Example. I tried implementing it with queue but the issue that I 
am facing is that if the queue becomes empty fr some time the stream is 
getting completed. Is there any way to create a continuous stream source 
and if there if the queue is empty wait till it got any element and then 
send it to the actor.

On Thursday, November 7, 2019 at 3:14:22 PM UTC+5:30, Felix Nensa wrote:
>
> Well, a GraphStage has a shape which you can define. If you define your 
> GraphStage to have an Outlet but no Inlet then it obviously becomes a 
> Source, right? 
> By Source.fromGraph(..your GraphStage ..) you can convert it into a 
> Source. 
> Or just look at the „NumbersSource“ example in 
> https://doc.akka.io/docs/akka/current/stream/stream-customize.html#custom-processing-with-graphstage
>  
> The name „NumbersSource“ even tells you that this GraphStage is a Source.

-- 
*
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*
>> 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/akka-user/544b3e8e-2de7-4f1d-a1e9-4575926d2b03%40googlegroups.com.


Re: [akka-user][deprecated] How can i create an akka stream from a java Native Queue?

2019-11-06 Thread Bishnu Shankar Pandey
Hi Felix,
Thank you for the response. I went through the link that you have shared 
with me. But in the documentation, I saw that the queue is used as a flow 
in the example. But in my use case, I want to use the queue as an Akka 
stream source and then send it to an actor. It will be very helpful for me 
if you will just write a code snippet on how to implement that. 

Regards,
Bishnu

On Wednesday, November 6, 2019 at 8:54:50 PM UTC+5:30, Felix Nensa wrote:
>
> You could wrap your queue in a GraphStage, which will give you a lot of 
> flexibility. 
> There are a lot of good examples (include some with queues) at 
> https://doc.akka.io/docs/akka/current/stream/stream-customize.html#custom-processing-with-graphstage
>  
>
> BR, Felix 
>
> > Am 06.11.2019 um 16:14 schrieb Bishnu Shankar Pandey <
> bishnu...@flutura.com >: 
> > 
> > Hi All, 
> > My use case is I want to create an Akka stream in which the source is a 
> java Queue. The stream should keep on the pooling values from the queue and 
> if the queue is empty then wait for the values in the queue. Akka stream 
> queue is another option but if in case of any failure I want to store the 
> values that are there in the queue (I don’t know how to do that with Akka 
> stream Queue). I tried the following: 
> > 
> > val source: Source[String 
> > , NotUsed] = Source.from(queue) 
> > source.ask( 
> > 1, actor, classOf[String], 10 
> >  seconds).runWith(Sink.ignore(), mat) 
> > 
> > I tried setting idleTimeOut and keepAlive properties but they are not 
> working. The stream goes to the Done state if there are no values in the 
> queue. 
> > 
> > 
> > 
> > 
> > 
> > Regards, 
> > 
> > Bishnu 
> > 
> > 
> > -- 
> > 
> *
>  
>
> > ** New discussion forum: https://discuss.akka.io/ replacing akka-user 
> google-group soon. 
> > ** This group will soon be put into read-only mode, and replaced by 
> discuss.akka.io 
> > ** More details: 
> https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced 
> > 
> *
>  
>
> > >>>>>>>>>> 
> > >>>>>>>>>> Read the docs: http://akka.io/docs/ 
> > >>>>>>>>>> Check the FAQ: 
> http://doc.akka.io/docs/akka/current/additional/faq.html 
> > >>>>>>>>>> Search the archives: 
> https://groups.google.com/group/akka-user 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups "Akka User List" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to akka...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/akka-user/7b86524e-a5a1-4eca-9a7b-44377c122dff%40googlegroups.com.
>  
>
>
>
>
>
>

-- 
*
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*
>>>>>>>>>> 
>>>>>>>>>>  Read the docs: http://akka.io/docs/
>>>>>>>>>>  Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/akka-user/30390583-e53d-4345-af9e-d706aec7bf43%40googlegroups.com.


[akka-user][deprecated] How can i create an akka stream from a java Native Queue?

2019-11-06 Thread Bishnu Shankar Pandey
Hi All,

My use case is I want to create an Akka stream in which the source is a 
java Queue. The stream should keep on the pooling values from the queue and 
if the queue is empty then wait for the values in the queue. Akka stream 
queue is another option but if in case of any failure I want to store the 
values that are there in the queue (I don’t know how to do that with Akka 
stream Queue). I tried the following:

val source: Source[String, NotUsed] = Source.from(queue)
source.ask(1, actor, classOf[String], 10 seconds).runWith(Sink.ignore(), mat)

I tried setting idleTimeOut and keepAlive properties but they are not 
working. The stream goes to the Done state if there are no values in the 
queue.



Regards,

Bishnu

-- 
*
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*
>> 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/akka-user/7b86524e-a5a1-4eca-9a7b-44377c122dff%40googlegroups.com.


Re: [akka-user][deprecated] How to recover Message if akka actor goes down for some reason?

2019-03-26 Thread Bishnu Shankar Pandey
Can you give me an example to handle the messagea??

On Tue, 26 Mar, 2019, 23:34 Brian Maso,  wrote:

> I suggest looking up "dead letters" (and maybe also "unhandled messages").
> What you are describing is a dead letter message, and there is a specific
> mechanism for routing and handling them in Akka.
>
> Best regards,
> Brian Maso
>
> On Tue, Mar 26, 2019 at 3:46 AM Bishnu Shankar Pandey <
> bishnu.pan...@flutura.com> wrote:
>
>> I want to solve two scenarios :
>>
>>  1. I have a sender Actor and a Receiver Actor how will the sender actor
>> know that the receiver actor is not responding. Terminated case can be used
>> to get a notification but what is the latency or the response time of the 
>> *Terminated
>> message*. I can't miss even a single message.
>>  2. How can I recover the messages that are currently in the mailbox of
>> the terminated actor?
>>
>> --
>>
>> *
>> ** New discussion forum: https://discuss.akka.io/ replacing akka-user
>> google-group soon.
>> ** This group will soon be put into read-only mode, and replaced by
>> discuss.akka.io
>> ** More details:
>> https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
>>
>> *
>> >>>>>>>>>>
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
>
> *
> ** New discussion forum: https://discuss.akka.io/ replacing akka-user
> google-group soon.
> ** This group will soon be put into read-only mode, and replaced by
> discuss.akka.io
> ** More details:
> https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
>
> *
> >>>>>>>>>>
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
*
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*
>>>>>>>>>> 
>>>>>>>>>>  Read the docs: http://akka.io/docs/
>>>>>>>>>>  Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user][deprecated] How to recover Message if akka actor goes down for some reason?

2019-03-26 Thread Bishnu Shankar Pandey
I want to solve two scenarios :

 1. I have a sender Actor and a Receiver Actor how will the sender actor 
know that the receiver actor is not responding. Terminated case can be used 
to get a notification but what is the latency or the response time of the 
*Terminated 
message*. I can't miss even a single message.
 2. How can I recover the messages that are currently in the mailbox of the 
terminated actor?   

-- 
*
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*
>> 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user][deprecated] Akka Cluster starding not able to register to Coordinator

2019-02-11 Thread Bishnu Shankar Pandey
I am trying to create an Akka Sharding Cluster. I want to use proxy only 
mode on one of the nodes just to route the message to the shard regions. I 
am getting the following Warning:

[WARN] [02/11/2019 17:04:17.819] 
[ClusterSystem-akka.actor.default-dispatcher-21] 
[akka.tcp://ClusterSystem@127.0.0.1:2555/system/sharding/ShardnameProxy] 
Trying to register to coordinator at 
[Some(ActorSelection[Anchor(akka.tcp://ClusterSystem@127.0.0.1:2551/), 
Path(/system/sharding/ShardnameCoordinator/singleton/coordinator)])], but 
no acknowledgement. Total [1] buffered messages.


**Main.java: ** Starts the cluster using the configuration from 
application.conf(code added latter)


object Main {
  val shardName = "Shardname"
  val role = "Master"
  var shardingProbeLocalRegin: Option[ActorRef] = None
  def main(args: Array[String]): Unit = {
val conf = ConfigFactory.load()
val system = ActorSystem("ClusterSystem",conf.getConfig("main"))
ClusterSharding(system).start(shardName,Test.props,
ClusterShardingSettings(system),ShardDetails.extractEntityId,ShardDetails.
extractShardId)
  }
}


**Test.java** : Entity for the Sharding Cluster


object Test {
  def props: Props = Props(classOf[Test])

  class Test extends Actor {
val log = Logger.getLogger(getClass.getName)


override def receive = {
  case msg: String =>
log.info("Message from " + sender().path.toString + " Message 
is " + msg)
sender() ! "Done"

}
  }

}


**MessageProducer.java(Proxy Only Mode)** Message Producer sends a message 
to the Shard every second. 

   
 object MessageProducer {

  var shardingProbeLocalRegin: Option[ActorRef] = None
  object DoSharding
  def prop:Props = Props(classOf[MessageProducer])
  var numeric : Long = 0
  def main(args: Array[String]): Unit = {
val conf = ConfigFactory.load
val system = ActorSystem("ClusterSystem",conf.getConfig(
"messgaeProducer"))
ClusterSharding(system).startProxy(Main.shardName,None,
extractEntityId,extractShardId)
shardingProbeLocalRegin  = Some(ClusterSharding(system).shardRegion(
Main.shardName))
val actor = system.actorOf(Props[MessageProducer],"message")
  }
}

class RemoteAddressExtensionImpl(system: ExtendedActorSystem) extends 
Extension {
  def address = system.provider.getDefaultAddress
}

object RemoteAddressExtension extends ExtensionKey[
RemoteAddressExtensionImpl]

class MessageProducer extends Actor{
  val log = Logger.getLogger(getClass.getName)


  override def preStart(): Unit = {
println("Starting "+self.path.address)
context.system.scheduler.schedule(10 seconds,1 second ,self,
DoSharding)
  }


  override def receive = {
case DoSharding =>
  log.info("sending message" + MessageProducer.numeric)
  MessageProducer.shardingProbeLocalRegin.foreach(_ ! "" + (
MessageProducer.numeric))
  MessageProducer.numeric += 1

  }

}


**application.conf: ** Configuration File 

   
 main {
  akka {
actor {
  provider = "akka.cluster.ClusterActorRefProvider"
}

remote {
  log-remote-lifecycle-events = on

  netty.tcp {
hostname = "127.0.0.1"
port = 2551
  }

}

cluster {
  seed-nodes = [
"akka.tcp://ClusterSystem@127.0.0.1:2551"
  ]

  sharding.state-store-mode = ddata
  auto-down-unreachable-after = 1s
}

akka.extensions = [
"akka.cluster.metrics.ClusterMetricsExtension", 
"akka.cluster.ddata.DistributedData"]
   
  }
}
messgaeProducer {
  akka {
actor {
  provider = "akka.cluster.ClusterActorRefProvider"
}

remote {
  log-remote-lifecycle-events = on

  netty.tcp {
hostname = "192.168.2.96"
port = 2554
  }

}

cluster {
  seed-nodes = [
"akka.tcp://ClusterSystem@127.0.0.1:2551"
//, "akka.tcp://ClusterSystem@127.0.0.1:2552"
  ]

  sharding.state-store-mode = ddata
  auto-down-unreachable-after = 1s
}

akka.extensions = ["akka.cluster.metrics.ClusterMetricsExtension", 
"akka.cluster.ddata.DistributedData"]

   
  }
}



Am I doing anything wrong? Is there any other way to apply for this 
approach. My main aim is to avoid Single Point of failure for my cluster. 
If any node goes down then it should not affect any other state. Can anyone 
help me with this?
 




 

-- 

[akka-user][deprecated] Not able to persist Actor

2018-11-09 Thread Bishnu Shankar Pandey (Trainee)
I want to persist events in Akka only when there is a failure in the actor. 
I am trying the following code to achieve persistence.

package persistence
import akka.actor._import akka.persistence._
case class Cmd(data: String)case class Evt(data: String)
case class ExampleState(events: List[String] = Nil) {
  def updated(evt: Evt): ExampleState = copy(evt.data :: events)
  def size: Int = events.length
  override def toString: String = events.reverse.toString}
class ExamplePersistentActor extends PersistentActor {
var list = new java.util.ArrayList[String]
  override def postStop (): Unit = {
println("inside postStop")
println(list.size())
import scala.collection.JavaConversions._
for( data <- list) {
  persist(Evt(s"${data}-${numEvents}")) { event ⇒
println("persisting")
updateState(event)
context.system.eventStream.publish(event)
if (lastSequenceNr % snapShotInterval == 0 && lastSequenceNr != 0)
  saveSnapshot(state)
  }
}
  }
  override def persistenceId = "sample-id-1"

  var state = ExampleState()

  def updateState(event: Evt): Unit =
state = state.updated(event)

  def numEvents =
state.size

  val receiveRecover: Receive = {
case evt: Evt ⇒ updateState(evt)
case SnapshotOffer(_, snapshot: ExampleState) ⇒ state = snapshot
  }

  val snapShotInterval = 1000
  val receiveCommand: Receive = {
case 'test =>
  println("test")
case Cmd(data) ⇒
  println(data)
  list.add(data)
case "print" ⇒ println(state)
  }}//#persistent-actor-example
object PersistentActorExample extends App {

  val system = ActorSystem("example")
  val persistentActor = system.actorOf(Props[ExamplePersistentActor], 
"persistentActor-4-scala")
  persistentActor ! 'test
  persistentActor ! Cmd("foo")
  persistentActor ! Cmd("baz")
  persistentActor ! Cmd("bar")
  persistentActor ! Cmd("buzz")
  persistentActor ! "print"
  Thread.sleep(1)
  persistentActor ! PoisonPill
  system.terminate()}


Can anyone help me in the above code? Is this code is the best approach to 
achieve what I want or Do I have to look for some other way?

One more approach I can think of is to add a shutdown hook but I don't know 
whether I will be able to use akka persistence in shutdown hook

-- 
*
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*
>> 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.