Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working sample for MySQL #30

Open
trailmax opened this issue Jan 22, 2017 · 14 comments
Open

Working sample for MySQL #30

trailmax opened this issue Jan 22, 2017 · 14 comments

Comments

@trailmax
Copy link
Member

No description provided.

@Iulian94
Copy link

Hi tailmax.

How soon can you get it working with MySql?
I would very much like to use this, but can't, because it's dependent soley on SqlServer.
Please respond asap, if possible.

@trailmax
Copy link
Member Author

trailmax commented Aug 14, 2018

@Iulian94 I had no immediate plans of using MySql, as I don't use it anywhere.

However currently provided SqlRepository can work with MySql. It will be a matter of providing correclty formed connection string (See PetaPoco documentation for that).

However I sense there will be an issue in creating an initial schema for the tables, as SQL I used worked in SQL Server and I never tested it in MySql. But you can try an report back if there is an issue.

@Iulian94
Copy link

Iulian94 commented Aug 14, 2018

@trailmax Thanks a lot for the quick response!

I've tried it, and it does not work.
It gives me an error that it can not login when Consuming the first message.
This is the stack trace, while I'm using a connection string format PetaPoco provides:
"server=localhost;UId=test;Pwd=test;database=test"

I've downloaded the binaries, will try to figure out what is wrong and come back to you.

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at NSaga.NSagaReflection.InvokeGenericMethod(Object invocationTarget, String methodName, Type genericParameterType, Object[] parameters) in C:\projects\nsaga\src\NSaga\NSagaReflection.cs:line 140
at NSaga.SagaMediator.Consume(IInitiatingSagaMessage initiatingMessage) in C:\projects\nsaga\src\NSaga\SagaMediator.cs:line 52
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)

at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at NSaga.ConnectionFactory.CreateOpenConnection() in C:\projects\nsaga\src\NSaga\SqlServer\IConnectionFactory.cs:line 46
at NSaga.SqlSagaRepository.Find[TSaga](Guid correlationId) in C:\projects\nsaga\src\NSaga\SqlServer\SqlSagaRepository.cs:line 61

@trailmax
Copy link
Member Author

@Iulian94 What is the actual message of the exception? How does your connection string look like?

@Iulian94
Copy link

Iulian94 commented Aug 14, 2018

@trailmax
Sorry for the late answer.. I've resolved that, it was because of some "charset" setting the connectionstring contained + I didn't use the override of the IConnectionFactory correctly.
I now have the following code:

container.Register<IConnectionFactory>(() => new NSagaMySqlProvider(connectionStringName), Lifestyle.Singleton);

container.RegisterNSagaComponents()
.UseSagaRepository<SqlSagaRepository>();

which works.

Small problem though.. MySql doesn't have the notion of Schemas, ergo, it crashes. I resolved this by taking the binaries and changing the const properties, but, it's not ok, as I'm not using the Nuget anymore.
Can we find a way around this?
I searched but couldn't without maybe implementing the whole SqlSagaRepository myself + replacing through the sql queries manually or creating MySqlSagaData and MySqlSagaHeaders (for the sole purpose of editing that small detail, aka table name).

@trailmax
Copy link
Member Author

@Iulian94 problem with renaming tables - it'll break all the existing solutions for people who are already using this package. Including my solutions.

So it'll have to be a separate implementation of the repository and other DB-related structure for MySql.

Since you already have the code working, would you like to share it via a Pull Request?

@Iulian94
Copy link

Iulian94 commented Aug 15, 2018

@trailmax I've made the pull request #37.
Please review it and push to nuget if it's all ok.
I've tested it and it works like this, without any additional IConnectionFactories (it's all included into the NSaga solution), or adding a complete new SagaRepository (for just a few lines):

container.RegisterNSagaComponents()
                    .UseSagaRepository<SqlSagaRepository>()
                    .UseMySql()
                    .WithConnectionStringName("local_db_name");

The only problem that I had is that SagaData is internal and I can't inject the IQueryWrapper, because the constructor in public.
Tried creating a different internal constructor for this, but as I don't know the ramifications for the DI, it would be best for you to do it, if necessary.

@Iulian94
Copy link

@trailmax Can you please tell me whether it would be possible to carry this out until tomorrow, and fast forward the deployment of the package?
Thanks in anticipation.

@trailmax
Copy link
Member Author

@Iulian94 I'm snowed under by requests for work in paid projects. And that unfortunately takes priority. So unlikely there will be a relese for tomorrow.

@Iulian94
Copy link

@trailmax Ok, thanks..
I don't think it will take you more than 30 minutes to test it out with a previous application to see it still works, approve and deploy it, as there weren't that many changes, so, please have a look, when you've got the time. This is also for a paid project for which I have a deadline until Friday evening and would like to get over with.
Sorry if I am being a bit pushy with this. Cool project, btw :)

@trailmax
Copy link
Member Author

@Iulian94 OK, you are setting my priorities, giving me a deadline and you are getting paid for your project. Should I ask to be paid for my time as well?

@Iulian94
Copy link

@trailmax I didn't mean it that way.. I just wanted to let you know that I also have a time limit on this, and that's why I was trying to push it that hard. Sorry if I was stressing you out so much with this.

@Iulian94
Copy link

@trailmax Thanks for doing the code review for the pull request.
I will do another pull request with only the minimal changes that are needed for it to work with MySql and nothing more.

@Iulian94
Copy link

Iulian94 commented Aug 16, 2018

@trailmax I've added the last pull request #38.
It's the most simplified version I could go with.
In case this still doesn't cut it, I will do another pull request with the duplicated SqlSagaRepository with just the table objects as differences, or implement the MySqlSagaRepository myself as a package user, like you said, and that's it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants