Coder Social home page Coder Social logo

Comments (4)

Aaronontheweb avatar Aaronontheweb commented on August 12, 2024

Hi @SeanKilleen,

could you post your exact HOCON configuration - without the connection strings, if they're sensitive?

from akka.persistence.postgresql.

SeanKilleen avatar SeanKilleen commented on August 12, 2024

@Aaronontheweb sure thing, it's below -- sorry, should have done that up front. The conn strings aren't sensitive at all, so no worries:

  <akka>
    <hocon>
      <![CDATA[
          akka { 
            loglevel=INFO,  
            loggers=["Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog"]
            }
            akka.persistence{
	              journal {
		              plugin = "akka.persistence.journal.postgresql"
		              postgresql {
			              # qualified type name of the PostgreSql persistence journal actor
			              class = "Akka.Persistence.PostgreSql.Journal.PostgreSqlJournal, Akka.Persistence.PostgreSql"

			              # dispatcher used to drive journal actor
			              plugin-dispatcher = "akka.actor.default-dispatcher"

			              # connection string used for database access
			              connection-string = "Server=localhost;Port=5432;User Id=admin;Password=example;Database=portfolioss;"

			              # default SQL commands timeout
			              connection-timeout = 30s

			              # PostgreSql schema name to table corresponding with persistent journal
			              schema-name = public

			              # PostgreSql table corresponding with persistent journal
			              table-name = event_journal

			              # should corresponding journal table be initialized automatically
			              auto-initialize = off
			
			              # timestamp provider used for generation of journal entries timestamps
			              timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
		
			              # metadata table
			              metadata-table-name = metadata

			              # defines column db type used to store payload. Available option: BYTEA (default), JSON, JSONB
			              stored-as = BYTEA
		              }
	              }

	              snapshot-store {
		              plugin = "akka.persistence.snapshot-store.postgresql"
		              postgresql {
			              # qualified type name of the PostgreSql persistence journal actor
			              class = "Akka.Persistence.PostgreSql.Snapshot.PostgreSqlSnapshotStore, Akka.Persistence.PostgreSql"

			              # dispatcher used to drive journal actor
			              plugin-dispatcher = ""akka.actor.default-dispatcher""

			              # connection string used for database access
			              connection-string = "Server=localhost;Port=5432;User Id=admin;Password=example;Database=portfolioss;"

			              # default SQL commands timeout
			              connection-timeout = 30s

			              # PostgreSql schema name to table corresponding with persistent journal
			              schema-name = public

			              # PostgreSql table corresponding with persistent journal
			              table-name = snapshot_store

			              # should corresponding journal table be initialized automatically
			              auto-initialize = on
			
			              # defines column db type used to store payload. Available option: BYTEA (default), JSON, JSONB
			              stored-as = BYTEA
		              }
	              }
              }
      ]]>
    </hocon>
  </akka>

from akka.persistence.postgresql.

SeanKilleen avatar SeanKilleen commented on August 12, 2024

More code for reference --

The code to init the actor, running inside of a quick console app:

var rando = actorSystem.ActorOf(Props.Create<MyActor>(), "rando-actor");
rando.Tell("Message1");
rando.Tell("message2");

And the actor code, which I think is straight out of the example:

    public class MyActor : ReceivePersistentActor
    {
        public class GetMessages { }

        private List<string> _msgs = new List<string>(); //INTERNAL STATE

        public override string PersistenceId
        {
            get
            {
                return "HardCoded";
            }
        }

        public MyActor()
        {
            // recover
            Recover<string>(str => _msgs.Add(str));

            // commands
            Command<string>(str => Persist(str, s =>
            {
                _msgs.Add(str); //add msg to in-memory event store after persisting
            }));

            Command<GetMessages>(get => Sender.Tell(new List<string>(_msgs)));
        }
    }
}

from akka.persistence.postgresql.

SeanKilleen avatar SeanKilleen commented on August 12, 2024

Didn't realize postrges was spitting out helpful errors in the console.

It looks like there's a query attempting to hit a payload column in the snapshot table.

portfolioss-db | 2018-02-23 14:39:50.902 UTC [115] ERROR:  column "payload" does not exist at character 159
portfolioss-db | 2018-02-23 14:39:50.902 UTC [115] STATEMENT:
portfolioss-db |                        SELECT persistence_id,
portfolioss-db |                            sequence_nr,
portfolioss-db |                            created_at,
portfolioss-db |                            manifest,
portfolioss-db |                            payload,
portfolioss-db |                            serializer_id
portfolioss-db |                        FROM public.snapshot_store
portfolioss-db |                        WHERE persistence_id = $1
portfolioss-db |                            AND sequence_nr <= $2
portfolioss-db |                            AND created_at <= $3
portfolioss-db |                        ORDER BY sequence_nr DESC

This column is not included in the SQL setup in the docs.

So it seems either:

  • There's a bug in the code looking for that column in that table
  • There's a missing line in the README creation docs
  • There's a missing step in the README migration docs.

Running an ALTER and adding the column appears to get it to work correctly..

@Aaronontheweb when you determine which of the above is the issue, let me know and I'll try to do a quick PR to address.

from akka.persistence.postgresql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.